movies = { harry_potter: 8}
puts "Wat wil u doen : "
choice = gets.chomp
case choice
when “add”
puts “welke film wilt u toevoegen”
title = gets.chomp
puts “welke rating krijgt deze film”
rating = gets.chomp
if movies[title.to_sym].nil?
movies[title.to_sym] = rating.to_i
puts “Deze film is toegevoegd”
else
puts “Deze flim is al toegevoegd”
end
when “update”
puts “Updated!”
when “display”
puts “Movies!”
when “delete”
puts “Deleted!”
else
puts “Error!”
end
but when I try to add a second time a movie I do not see the message
that the film is al toegevoegd.
What do I do wrong here ?
movies = {harry_potter: 8}
loop do
# your current code
end
and kill the program with Control-C when you want to finish the loop. Of
course, when you run the program again the modifications to the hash are
gone, but you’ll get that first start working which is going to feel
great
:).
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.