NilClassのnil?を再定義するとRuby(irb)が壊れる
class NilClass;def nil?;false;end;end
して、
nil.hoge
とすると、落ちる。
% ruby -v [~] ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9] % echo $OSTYPE [~] darwin9.0% irb [~] irb(main):001:0> class NilClass;def nil?;false;end;end => irb(main):002:0> nil.hoge /opt/local/lib/ruby/1.8/irb/slex.rb:235:in `match_io': undefined method `call' for nil:NilClass (NoMethodError) from /opt/local/lib/ruby/1.8/irb/slex.rb:76:in `match' from /opt/local/lib/ruby/1.8/irb/ruby-lex.rb:287:in `token' from /opt/local/lib/ruby/1.8/irb/ruby-lex.rb:263:in `lex' from /opt/local/lib/ruby/1.8/irb/ruby-lex.rb:234:in `each_top_level_statement' from /opt/local/lib/ruby/1.8/irb/ruby-lex.rb:230:in `loop' from /opt/local/lib/ruby/1.8/irb/ruby-lex.rb:230:in `each_top_level_statement' from /opt/local/lib/ruby/1.8/irb/ruby-lex.rb:229:in `catch' from /opt/local/lib/ruby/1.8/irb/ruby-lex.rb:229:in `each_top_level_statement' from /opt/local/lib/ruby/1.8/irb.rb:146:in `eval_input' from /opt/local/lib/ruby/1.8/irb.rb:70:in `start' from /opt/local/lib/ruby/1.8/irb.rb:69:in `catch' from /opt/local/lib/ruby/1.8/irb.rb:69:in `start' from /opt/local/bin/irb:13 %