7. Update what am i doing wrong?!?!


#1





(ruby):25: syntax error, unexpected tFID, expecting keyword_then or ';' or '\n'
(ruby):34: syntax error, unexpected keyword_when, expecting $end
when "display"
^

movies = {
    snatch: 4,
    lion_king: 3,
    finding_nemo: 2
}

puts "would you like to add, update, display, or delete a movie?"
choice = gets.chomp

case choice
when "add"
puts "what is the title of the movie?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "what is the rating of the movie?"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "the movie and rating has been added!"
else
    puts "that movie already exists!"
end

when "update"
puts "what do you want to update?"
title = gets.chomp
if movies[title.to_sym]nil?
    puts "that movie is not found!"
else
    puts "what is the new rating of the movie?"
    rating = gets.chomp
    movies[title.to_sym] = rating.to_i
    puts "#{title} has been updated with a new rating of #{rating}"
end

when "display"
puts "Movies!"

when "delete"
puts "Deleted!"

else
    puts"Error!"
end

not sure what im doing wrong


#2

Can you spot the error?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.