Hi i´m new on programming and i want to learn/know if this code:
movies = {
StarWars: 4.8,
Divergent: 4.7
}
puts "What would you like to do? "
choice = gets.chomp
case choice
when “add”
puts "What movie would you like to add? "
title = gets.chomp.to_sym
puts "What rating does the movie have? "
rating = gets.chomp.to_i
if movies[title].nil?
movies[title]= rating
puts “Got it!”
else
puts “That movie already exists daugh”
end
when “update”
puts “What movie are you searching for?”
title=gets.chomp.to_sym
if movies[title].nil?
puts “Sorry dude, that movie isn’t in the hash”
else
puts “Ok, please write your rating of that movie”
movies[title]= gets.chomp.to_i
end
when “display”
movies.each do |movie,rate|
puts “#{movie}: #{rate}”
end
when “delete”
puts “Deleted!”
else
puts “Error!”
end
#end of the code
can be converted to continue doing actions(same, other) despite of doing 1 action and then have to start over the program.
Thank you very much!
pd: my english is far to be well but i try to be the more clear as possible
link of excercise = https://www.codecademy.com/courses/learn-ruby/lessons/a-night-at-the-movies/exercises/delete?action=resume_content_item