[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

puts nil generates "nil\n"

Brian Candler

11/6/2004 1:46:00 PM

$ ruby -v
ruby 1.8.2 (2004-07-29) [i386-freebsd5]
$ ruby -e 'puts nil'
nil
$ ruby -e 'puts nil.to_s'

$

This is strange and seems to conflict with the documentation in ri, which
says:

- Kernel.puts is the same as $stdout.puts

- IO.puts says

Writes the given objects to _ios_ as with +IO#print+.

- IO.print says

Objects that aren't strings will be converted
by calling their +to_s+ method.

So is 'nil' a special case for puts/print? Is the documentation wrong?

Regards,

Brian Candler.


1 Answer

ts

11/6/2004 1:59:00 PM

0

>>>>> "B" == Brian Candler <B.Candler@pobox.com> writes:

B> So is 'nil' a special case for puts/print?

nil is a special case for #print, #puts


Guy Decoux