Closed JoshCheek closed 7 years ago
The nil on 25 seems wrong, also behaves weirdly if I delete the space on 38
nil
require 'stringio' # => false $stdout = StringIO.new # => #<StringIO:0x007fdc0b0ec948> class Fixnum def inspect c = (chr rescue 'none') # => "\x00", "\x01", "\x03", "\e", "\x04", "\x01", "\x1F", " ", "1" sprintf '%08b %3d %6p', self, self, c # => "00000000 0 \"\\x00\"", "00000001 1 \"\\x01\"", "00000011 3 \"\\x03\"", "00011011 27 \"\\e\"", "00000100 4 \"\\x04\"", "00000001 1 \"\\x01\"", "00011111 31 \"\\x1F\"", "00100000 32 \" \"", "00110001 49 \"1\"" end # => :inspect end # => :inspect $/ =~ // # => 00000000 0 "\x00" # "\e[4" $. = -~$. # => 00000001 1 "\x01" $; = $. | $. << $. # => 00000011 3 "\x03" $; = $; | $; << $; # => 00011011 27 "\e" $\=$& << $; # => "\e" $. <<= $. << $. # => 00000100 4 "\x04" $\ <<= $; | $. << $. # => "\e[" $.^=-~$. # => 00000001 1 "\x01" $\ <<= ~-~$.&$;<<$. # => "\e[4" # "m " $.=~-$.^$. # => nil $, = $&.<<$.|$;<<-~$. # => "m" $; = $; | -~$; # => 00011111 31 "\x1F" $; = -~$; # => 00100000 32 " " $, = $, << $; << $; # => "m " # "1" $_=$;|~-$;^~-$;>>-~$.<<$. # => 00110001 49 "1" # print $>.<<$\+$&<<$_<<$,<<$\ $>.<<$&.<<$_=-~$_ # => #<StringIO:0x007fdc0b0ec948> $><<$,<<$/<<$\ $>.<<$&.<< -~-~$_ # => #<StringIO:0x007fdc0b0ec948> $><<$,<<$\ $>.<<$&<<-~$_<<$,<<$/ # => #<StringIO:0x007fdc0b0ec948> $stdout.string == # => "\e[41m \e[42m \n\e[44m \e[43m \n" "\e[41m \e[42m \n\e[44m \e[43m \n" # => true
The nil is correct, this is what's happening:
1 =~ 0 # => nil
The space is correct, as well. The space changes whether it's invoking -@ on the RHS or - on the LHS. It's the difference between:
-@
-
[].<<(-1) [].<<() - 1
The
nil
on 25 seems wrong, also behaves weirdly if I delete the space on 38