6.Error! Error!


#1



Okay, so i have been trying to solve this for a while now, but i just dont get it. The thing is that when i type in a movie that already is in the hash (Finding Nemo for example) it says that the movie has been added but that shouldnt be possible since it already is there. And the worst of all is that it says that the excercise is okay and i can move on, when its definetely not okay because it doesnt tell me that the movie is already on the list, eventhough thats what its supposed to do. Please help me out and thank you in advance.

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


Here s what i have so far

movies = {
  Edge_of_Tomorrow: 4,
  The_Incredible_Life_of_Walter_Mitty: 5,
  Finding_Nemo: 3
  }

puts "So, what now pal?"
puts "Maybe you want to add a new movie? Then type add"
puts "Or you just wanna update a movie? Then type update"
puts "Or maybe you wanna display all the movies? Then type display"
puts "Last option? Delete a movie obviously. If thats it then type delete, dude"

choice = gets.chomp
case choice
when 'add'
  puts "Which movie do you wanna add?" 
  title = gets.chomp
  if movies[title.to_sym].nil?
     puts "And what rating do you wanna give it? (from 0 to 5)"
     rating = gets.chomp
     movies[title.to_sym] = rating.to_i
     puts "Great, your movie has been added"
  else
     puts "Sorry buddy, that movie is already on the list"
   end
   
 when 'update'
      puts "Updated"
 when 'display'
      puts "Movies!"
 when 'delete'
      puts "Deleted!"
 else
      puts "Error!"
end


#2

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