6. Error! Error! I've made an Error!


#1

I don't have a complete handle on using if/else statements in conjunction with .nil . Can anyone clarify my mistake in this program??


movies = {
'Back to the Future' => '4'
}

puts "Do you like this movie?"
choice = gets.chomp

case choice
when "add"
puts "Which movie?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "How good is it?"
rating = gets.chomp
else
puts "Movie is already listed."
when "update"
puts "Upadated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end

movies = {}
movies[title.to_sym] = rating.to_i
puts rating + movies[title]


#2
if movies[title.to_sym].nil?
    puts "How good is it?"
    rating = gets.chomp
else
    puts "Movie is already listed."

You're missing an end keyword.


#3

Thanks! I didn't think you'd have to nest ends but I'm sure I've done that in an earlier exercise. I appreciate all the help.