Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Array
- # swap index of a & b of caller array
- # pry> [1, 2, 3, 4, 5].swap!(0, 4)
- # pry> [5, 2, 3, 4, 1]
- def swap!(a, b)
- self[a], self[b] = self[b], self[a]
- self
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement