be_1va
Last Updated: September 14, 2017
·
17.75K
· fabsays
Ef3e156f7b5fb36fb1dc5d98ceda5d0e

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]
Say Thanks
Respond

1 Response
Add your response

18433
None

awesome!

over 1 year ago ·