It’s highly probable this question has been asked, but I can’t find the answer.
I have four variables:
a,b,c,d = [a,b,c,d].map{|myvar| myvar+1 }
How can I make this line more DRY (keeping it compact), i.e., achieve the same changes without repeating variable names?
i have a growing suspicion that short answer (for this specific example with integers) is “no way”
due to the same reason as described in the answer in my previous question:
replacing referenced Integer value in Ruby like String#replace does
update:
if variables we operate on are an Array, Hash or String, and they keep the same datatype after the performed operation, it’s drier, more compact and saving memory to use replace