Forum: Ruby Re: setting nil to zero

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Peña, Botp (Guest)
on 2006-02-23 13:27
(Received via mailing list)
Robert K. [mailto:removed_email_address@domain.invalid] wrote:

#Why so complicated?  Why not just
#class NilClass
#  def +(n) n end
#end

why can i not see the simple light? :-)

#Note, I recommend to use the veriant with 0 as default value for Hash
#lookups because that avoids tampering with standard classes.

thanks for the advice, Robert.
kind regards -botp

#Cheers
#
#    robert
#
#
#
This topic is locked and can not be replied to.