Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. # normal usage in array method
  2. @tuple.swap i, random
  3.  
  4. # becomes
  5. swap(@tuple, i, random)
  6.  
  7. # normally in tuple.rb
  8. def swap(a, b)
  9. temp = at(a)
  10. self[a] = at(b)
  11. self[b] = temp
  12. end
  13.  
  14. # in array rb becomes
  15.  
  16. def self.swap(tuple ,a, b)
  17. temp = tuple.at(a)
  18. tuple[a] = tuple.at(b)
  19. tuple[b] = temp
  20. end
  21. private :swap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement