-
-
Save anonymous/f8ca3a643b7e1817353559d70db543f3 to your computer and use it in GitHub Desktop.
Does Ruby already have a deep `find` for collections ?
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 | |
include Enumerable | |
def pull_value(val) | |
self.flatten.select { |element| element == val } | |
end | |
end | |
result = nested_array.pull_value("ham") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment