Created
April 17, 2015 16:27
-
-
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 file contains hidden or 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
# 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