Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # normal usage in array method
- @tuple.swap i, random
- # becomes
- swap(@tuple, i, random)
- # normally in tuple.rb
- def swap(a, b)
- temp = at(a)
- self[a] = at(b)
- self[b] = temp
- end
- # in array rb becomes
- def self.swap(tuple ,a, b)
- temp = tuple.at(a)
- tuple[a] = tuple.at(b)
- tuple[b] = temp
- end
- private :swap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement