be_1va
Last Updated: October 11, 2018
·
24.24K
· fabsays

Swap two elements of an array in Ruby

array = [4, 5, 6, 7]

array[0], array[3] = array[3], array[0]

array # => [7, 5, 6, 4]

1 Response
Add your response

18433

awesome!

over 1 year ago ·