I have an array made from variables, and I want to perform the same operation on each, and store the result in the original variable:
(one, two, three) = [1, 2, 3]
[one, two, three].map!{|e| e += 1}
# => [2, 3, 4]
# But:
[one, two, three]
# => [1, 2, 3]
# You have to:
(one, two, three) = [one, two, three].map{|e| e += 1}
# => [2, 3, 4]
[one, two, three]
# => [2, 3, 4]
This doesn't seem like the "right way" to do it, but I'm not managing to find that "right way". I also have some vague ideas as to what's going on, but I'm not too sure, so an explanation would be appreciated.
My actual use case is that I've got named parameters and I'm e = File.new(e) if e.is_a? String