my solution is like
if (not (defined?(@results).nil?)) @results += "run" else @results = "run" end
but I believe that there is something simpler ...
I would probably do it like this:
@results = @results.to_s + "run"
This works because NilClass defines a #to_s method that returns a zero-length String, and because instance variables are automatically initialized to nil.
NilClass
#to_s
1.4m articles
1.4m replys
5 comments
57.0k users