ruby hash get key code example
Example 1: ruby get key
hash = {"apple" => "fruit", "carrot" => "vegetable"}
array = hash.keys #=> ["apple", "carrot"]
Example 2: how to access hash value ruby
my_hash["key"] #=> "value"
hash = {"apple" => "fruit", "carrot" => "vegetable"}
array = hash.keys #=> ["apple", "carrot"]
my_hash["key"] #=> "value"