Not my Type


#1



Hello everyone
This is my first post so I would like thank everyone for all your work here. Going to my problem below:
Codecademy let me go through this exercise but I still have an error "undefined method `+' for nil:NilClass"
Could you tell me, looking on my code what I'm doing wrong?


movies = {
    Pearl_Harbor: 4,
    Samsung: 1,
    Lokum: 3,
    Computer: 2,
}

puts    "What would you like to  do?"
puts    "Type 'add' to add movie to library"

choice = gets.chomp


case choice
when "add"
    
    puts "Tell me the title of the film which you would like to add"
        title = gets.chomp
    
    puts "What is the rating of this movie? You can choose between 1 and 5, where 5 is one           of the best movie you ever saw"
        rating = gets.chomp

    movies[title.to_sym]=rating.to_i
    movies[title]+rating
    puts "The movie #{title} was added to library with rating #{rating}"    

when "update"
    puts "Updated!"

when "display"
    puts "Movies!" 
  
when "delete"
    puts "Deleted!"

else
    puts "Error!"
  
end

Thanks :slight_smile:
Konrad


#2

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