Puts nil generates "nil\n"

$ 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.

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

nil is a special case for #print, #puts

Guy Decoux