Created
January 1, 2015 16:37
-
-
Save yuki24/201b0bfc582f41d5663d to your computer and use it in GitHub Desktop.
Array#to_proc
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
class Array | |
def to_proc | |
->(obj) { obj[first] } | |
end unless method_defined?(:to_proc) | |
end | |
users = [ | |
{name: "Matz"}, | |
{name: "DHH"}, | |
{name: "Yuki"} | |
] | |
users.map(&[:name]) | |
# => ["Matz", "DHH", "Yuki"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment