On 2/23/07, tchick <monsorno-nospam / gmx.de> wrote:
> Hi *,
>
> I like to concatenate a string out of some variables, some of which
> are nil. Instead of getting always a "can't convert nil into String
> (TypeError)" message, I would like to have "nil" appended to my
> string, as in Java null objects are printed as null in Strings.
> Something like this:
>
> words = Hash.new
> words[0]="one"
> allWords = "all words:"
> allWords << words[0]
> allWords << words[1]
> # --> can't convert nil into String (TypeError)
>
> Is this possible? Or how can I handle nil objects for this case?
>
> Thanks.
>

Is this what you are looking for?

http://www.rubycentral.com/book/ref_c_hash.html#Hash.new

Harry
-- 
http://www.kakueki.com/ruby/list.html