From: Gavin Sinclair Date: 2002-10-17T21:09:37+09:00 Subject: Re: behaviour of nil From: "C�dric Foll" > Hi, > > why the '+' method of nil isn't defined ? > > For exemple: > nil + "aaa" should return "aaa" > nil + 3 should return 3 > nil + [1,2] should return [1,2] .... > Perl works like that (at least for the first two exemple). > It is convenient to do something like > while gets do > res += $_ > end > > without having to do res = "" before. > > Regards. > > -- > Cedric Foll > courriel: cedric dot foll at laposte dot net Some people will give you good reasons why it's not like that in Ruby. You should try implementing it yourself and see if it causes you any problems down the track. class NilClass def +(other) other end end Cheers, Gavin