Puts and adding the key and value to an existing Hash


Please help!!! The puts is not working right, and I don't know how to correctly add a key and value to an existing Hash. Any help will be super usefull!!


(ruby):13: syntax error, unexpected '=', expecting keyword_end
movies (title) = rating
(ruby):15: syntax error, unexpected keyword_when, expecting $end
when "updade"

movies = {
    Test: 5,

puts = "What to do? (add, update, display, delete)"
choice = gets.chomp

case choice
when "add"
    puts "Enter the movie title: "
    title = gets.chomp
    puts = "Now enter the rating: "
    rating = gets.chomp
    movies (title) = rating
    puts "Movie and rating added."
when "updade"
    puts "Updated!"
when "display"
    puts "Displayed!"
when "delete"
    puts "Deleted!"
    puts "Error!"


puts = "Now enter the rating: "

remove the = sign

and here

movies (title) = rating

use [] brackets instead ()


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