I guess this should go on the Ruby-list, but I failed to find what
it’s called, so here goes.
This might be a bit of a stupid question, but I would like to
understand why what causes this behaviour:
params[‘string’] = “foo_bar”
@baz = params[‘string’]
@baz.gsub!(/[_]/, ’ ') #replace underscore with space
puts params[‘string’] # => “foo bar”
Why whould gsub!() alter the value in params? Same goes if I copy it
again and as far as I can tell even if variables doesn’t have the
@-sign or using any other string operator ending with an explamation
Does my equal sign make references rather then copies? Is there only
some occasions when that is true?
Thanks in advance,