Groovy swap variables like ruby
groovy, swap
Solution
Just use parentheses for multiple assignment
(x,y) = [ y, x ]
Problem
Which is the best way to swap to variable in Groovy? Is it possibile to do something like in Ruby? x,y = y,x
groovy, swap
Just use parentheses for multiple assignment
(x,y) = [ y, x ]
Which is the best way to swap to variable in Groovy? Is it possibile to do something like in Ruby? x,y = y,x