From: Francis Cianfrocca Date: 2006-09-12T00:45:37+09:00 Subject: Re: string as nil or empty string? On 9/11/06, aidy wrote: > Hi, > > With everything in Ruby being an object, should a string be initialised > as an empty string > > e.g. > > a_string = "" > > or nil > > e.g > > a_string = nil > > cheers > > aidy > > > nil signifies the absence of an object, so you can always set a variable to nil, regardless of whether the variable was previously bound to an object of type String, some other type, or indeed nil. I wonder if what you really want is to impute a logical-false value to an empty string, to enable expressions like s = String.new ... unless s # here the string is known to be not empty end This would violate a fairly deep expectation that the only values in Ruby which evaluate to logical-false are nil and instances of class FalseClass (of which there is only one, of course).