O'Reilly logo
  • Ronald Cosentino thinks this is interesting:

“When you deleted the key, it gave you the value back!”

Jim nodded. “That’s what the delete method does!” he said. “That way, if we had wanted to use the value of the deleted key for something, we could have saved it into a variable, like this:

From

Cover of Ruby Wizardry

Note

When you delete a key from a hash with the .delete method it returns the value. You can set a variable equal to the menu_drinks.delete(drinks) so you can capture the reutrned value!