Else not executing - Error! Error!


#1

https://www.codecademy.com/courses/learn-ruby/lessons/a-night-at-the-movies/exercises/error-error

Even when I add an existing movie title with exact spacing and capitalization, the “if” case evaluates as true and continues prompting for rating, instead of saying the title already exists.



movies= {
  "The Big Sick" => 4,
  "Wonder Woman" => 4,
  "Baby Driver" => 3,
  "Thor:Ragnarok" =>3
  }

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
  	if movies[title.to_sym].nil?
  		puts "What rating does #{title} have?"
      rating=gets.chomp
      movies[title.to_sym]=rating.to_i
      puts "#{title} with rating of #{rating} has been added!"
		else
      puts "#{title} already exists."
    end
  when "update"
  	puts "Updated!"
  when "display"
  	puts "Movies!"
  when "delete"
  	puts "Deleted!"
	else
  	puts "Error!"
end



#2

For this lesson, just check the title without converting. Symbols come up in a later lesson.


#3

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