Just curious if there is a more elegant way to set a variable if it happens
to not exist yet. I often find I am doing somthing like the following:

    regex = ''
    10.times { regex += '.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*\n' }

Is there some prettier way to within the second line create the variable if
it does not exist yet? The above just looks ugly. I know I could use a class
variable but that also does not seem right as I do not need it to be a class
variable:

    10.times { @regex += '.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*,.*\n' }

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to