N 9 delete


#1

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

https://www.codecademy.com/en/courses/ruby-beginner-en-0i8v1/0/9?curriculum_id=5059f8619189a5000201fbcb#

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}."
end
when "update"
puts "Updtated"
when "display"
movies.each do |movie, rating|
puts "#{movie}: #{rating}"
end
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!"
else
puts "The movie #{title} with rating: #{rating} has now been deleted."
puts movies
end
end

`


#2

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


#3

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