From: "David A. Black" Date: 2005-07-26T04:25:58+09:00 Subject: Re: Newby question 'unless' Hi -- On Tue, 26 Jul 2005, Patrick Gundlach wrote: > Hello David, > >> Conditionals give you nil when they're not met, and nil.to_s is an >> empty string, so you don't have to specify a literal empty string in >> cases like this. > > Sure, but not in the case I posted: > >> def to_s >> "#{@a}" + (@a == 0 ? "" : "#{@b}" ) >> end > > > -:4:in `+': cannot convert nil into String (TypeError) Whoops, I thought I was being helpful by showing an intermediate step but indeed that + nil would not work :-) David -- David A. Black dblack@wobblini.net