N 9 delete


< Oops : error "can't convert Symbol into Integer" >


Hello,I don't understand my error here : can you help me with that? :slight_smile:

movies = "harry potter:", 5
puts " what do you want to do "

choice = gets.chomp
case choice
when "add"
puts "please enter the movie title"
title = gets.chomp
if movies[title.to_sym].nil?
puts "What's the rating? (Type a number 0-4.)"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "#{title} has been added with a rating of #{rating}."
when "update"
puts "Updtated"
when "display"
movies.each do |movie, rating|
puts "#{movie}: #{rating}"
when "delete"
puts " want to delete which movie ?"
title = gets.chomp
movies [title.to_sym] = rating.to_i
if movies [title.to_sym].nil?
puts "There is no movie called #{title} to delete!"
puts "The movie #{title} with rating: #{rating} has now been deleted."
puts movies



There can be no white space between identifier and index block.


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