Skip to content

Instantly share code, notes, and snippets.

@bjfish
Created March 10, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjfish/5f77ee3fc724c609853e to your computer and use it in GitHub Desktop.
Save bjfish/5f77ee3fc724c609853e to your computer and use it in GitHub Desktop.
before and after tuple.rb method
# 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