Not My Type (did you add to_sym error)


#1




Keeps asking if I've added to_i or to_sym. I believe I did in the correct format


movies = Hash.new
movies = {
    Lion: 4,
    Tigers: 4,
    Pigs: 1,
    Bears: 3
}

puts "What would you like to do?"
choice = gets.chomp
case choice
when "add"
    puts "What title would you like to add?"
  title = gets.chomp
  puts "What is the rating of the movie? (Number 1-4)"
  rating = gets.chomp
  movies[title.to_sym] = rating.to_i
  puts "Your movie has been added"
when "update"
  puts "Updated"
when "display"
  puts "Displayed"
when "delete"
  puts "Deleted"
else
    puts "Error!"
end


#2

You don't need this line because,

this already a Hash,

And the reason you are getting that error is because you have not displayed the added movie as desired,

"Your movie has been added"

should use the #{} placeholder and display it like,

puts "#{title}, has been added with the rating of #{rating}."


#3

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