Created
October 21, 2010 10:17
-
-
Save nickyp/638254 to your computer and use it in GitHub Desktop.
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
# destructures the parameter values according to the order of the sorted keys | |
# Usage: | |
# hash = { :macbook => 1, :iphone => 2, :ipad => 3 } | |
# ipad, iphone, macbook = destructuring_bind(hash) | |
def destructuring_bind(hash) | |
hash.sort_by {|k, v| k.to_s }.map {|e| e[1] }.flatten | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment