Created
March 10, 2015 13:57
-
-
Save bjfish/f247a80ffd5b0fa2306a to your computer and use it in GitHub Desktop.
before and after tuple.rb method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment