From: Eric Hodel Date: 2007-10-11T16:11:33+09:00 Subject: Re: what does print call internally? On Oct 10, 2007, at 19:52 , Joel VanderWerf wrote: > Eric Hodel wrote: >> On Oct 10, 2007, at 15:31 , Martin DeMello wrote: >>> irb(main):001:0> puts nil >>> nil >>> => nil >>> irb(main):002:0> print nil >>> nil=> nil >>> irb(main):003:0> class NilClass >>> irb(main):004:1> def inspect >>> irb(main):005:2> "foo" >>> irb(main):006:2> end >>> irb(main):007:1> end >>> => foo >> it calls #to_s. > > Hm. What's going on here then: > > $ ruby -e 'p nil.to_s' > "" > $ ruby -e 'print nil' > nil switch (TYPE(argv[i])) { case T_NIL: rb_io_write(out, rb_str_new2("nil")); break; default: rb_io_write(out, argv[i]); break; } -- Poor workers blame their tools. Good workers build better tools. The best workers get their tools to do the work for them. -- Syndicate Wars