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:
What I’m actually trying is this: I have an array of hashes,
and I like to make strings out of them. Some of the hashes
do not have values for some keys, so when putting together
the string, I get the error message, but I just want to add
“nil” or something else for this case.
What I’m actually trying is this: I have an array of hashes,
and I like to make strings out of them. Some of the hashes
do not have values for some keys, so when putting together
the string, I get the error message, but I just want to add
“nil” or something else for this case.
words = Hash.new “nil” # I suppose this is what Harry thought of
words[0]=“one”