Created
July 31, 2013 15:05
-
-
Save the-architect/6122780 to your computer and use it in GitHub Desktop.
Reverse the order of a hash
This file contains hidden or 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
class Hash | |
# reverses the order of a hash | |
# { a: 100, b: 200 }.reverse => { b:200, a:100 } | |
def reverse | |
self.class[to_a.reverse] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment