Skip to content

Instantly share code, notes, and snippets.

@matsuda
Created December 13, 2010 02:27
Show Gist options
  • Save matsuda/738584 to your computer and use it in GitHub Desktop.
Save matsuda/738584 to your computer and use it in GitHub Desktop.
Hashの値もflattenする
class Array
def flatten_with_hash
inject([]){ |r, h|
if h.is_a?(Hash)
r << h.keys.flatten_with_hash
r << h.values.flatten_with_hash
else
r << h
end
r
}.flatten
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment