Skip to content

Instantly share code, notes, and snippets.

@samuraijane
Created April 17, 2015 16:27
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 samuraijane/9321ba4087dbd581dd62 to your computer and use it in GitHub Desktop.
Save samuraijane/9321ba4087dbd581dd62 to your computer and use it in GitHub Desktop.
To pull just the keys out of a hash, you have a few options but they are not interchangeable.
# This works in IRB but I could not get it to output in a browser. The command
# 'puts' will not output to a browser but with other methods, doing something
# like '{ |x| x}' usually works but not here.
hash.each_key { |x| puts x }
#This works to output to a browser. The output is an array.
hash.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment