Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2015 12:49
Show Gist options
  • Save anonymous/46ddeaa416d5ce0fe905 to your computer and use it in GitHub Desktop.
Save anonymous/46ddeaa416d5ce0fe905 to your computer and use it in GitHub Desktop.
books = {
Wheel_of_Time: 6,
Mistborn: 5,
Alchemist: 7,
}
puts "What would you like to do? Options: (add) (update) (delete) (list)"
choice = gets.chomp
case choise
when "add"
puts "What book would you like to add to your hash?"
title = gets.chomp
if book[title.to_sym] = .nil?
puts "What rating do you give this book? (Between 1 and 10)"
rating = gets.chomp
books [title.to_sym] = rating.to_i
puts "#{title} has been added to your hash with a rating of #{rating}"
else puts "That book is already in your hash"
end
puts books
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment