Ruby’s Parallel Assignment
array = [1, 2, 3] left_index = 0 right_index = -1 array[left_index], array[right_index] = array[right_index], array[left_index] p array # => [3, 2, 1]
The idiom on line 5 is used to swap two values without the use of an intermediate variable. Good to know.
Also called simultaneous assignment or sometimes **multiple↩︎