Groovy交换变量,如ruby

Pie*_*tro 7 groovy swap

哪个是在Groovy中交换变量的最佳方法?

是否有可能像Ruby一样?

x,y = y,x

tim*_*tes 16

只需使用括号进行多次分配

(x,y) = [ y, x ]
Run Code Online (Sandbox Code Playgroud)