5. Not My Type (How does this work!)


#1



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

Oops, try again. Did you call .to_sym on title and .to_i on rating before adding them to the hash?

This is the error message I keep getting. I don't know where to put the to_sym or to_i.


movies = {
    'Inception' => '4'
}
puts "What would you like to do?"

choice = gets.chomp
case choice
when "add" 
    puts "Movie title!" 
    title = []
    title = gets.chomp
    title.to_sym
when "update"
    puts "Rating!"
    rating = []
    rating = gets.chomp
    rating.to_i
    movies["title"] = rating
    puts "You added #{title} and #{rating}."
when "display"
    puts "Movies!"
when "delete"
    puts "Deleted!"
else
    puts "Error!"
end

Here's what I have. How do I do it? Thanks


#2

This is not an in place operation. It needs to be assigned to a variable, passed as an argument to a method, or used to reference a hash.

movies[title.to_sym] = rating.to_i

Suggest go back to lesson 1 and review the example so you include all the steps in your code.


#3

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