Skip to content

Instantly share code, notes, and snippets.

View abigezunt's full-sized avatar

Abby Howell abigezunt

View GitHub Profile
def values(hsh, key)
return [] if !hsh.kind_of? Hash
v = hsh[key] ? [hsh[key]] : []
hsh.values.select{|i| i.kind_of? Hash or i.kind_of? Array}.each do |val|
if val.kind_of? Hash
v+= values(val, key)
else
val.each {|i| v+= values(i, key)}
end
end