Skip to content

Instantly share code, notes, and snippets.

@seki
Created March 15, 2018 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seki/af522b403c29a18abd66d3e79a22e82e to your computer and use it in GitHub Desktop.
Save seki/af522b403c29a18abd66d3e79a22e82e to your computer and use it in GitHub Desktop.
class Array
def keys
0...size
end
end
def find(it, key, &blk)
it.keys.each do |k|
v = it[k]
k == key ? yield(v) : find(v, key, &blk)
end
rescue
# nop
end
e = ENV.to_hash
e['more'] = ENV.to_hash
e['x'] = [1,2,3, ENV.to_hash]
find(e, 'SHELL') {|x| p x}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment