Ruby Ruby Collections Ruby Hashes Working with Hash Keys

Simon Goldman
Simon Goldman
1,028 Points

hash

im trying to add a new varible caled "food" set to true??

hash.rb
hash = { "name" => "Bread", "quantity" => 1, "calories" => 100}
hash.has_key?("calories") 
hash["food"] = "true"

1 Answer