Ruby hashes, getting a key which programatically changes [closed]

Actually it’s almost the same:

my_key = :name
my_hash = { name: 'Joe', age: 52 }
my_hash[my_key]
#=> "Joe"

See http://www.ruby-doc.org/core-2.1.1/Hash.html

Browse More Popular Posts

Leave a Comment