6. Error! Error!



(ruby):1: syntax error, unexpected tCONSTANT, expecting tASSOC
17 Miracles : 10,

I just want to use the syntax, key followed by ":"

movies = {
    17 Miracles : 10,
    Superman : 10

puts "What would you like to do?"
puts "Please type one of the following according to your choice"
puts "add - Add a movie"
puts "update - Update a movie in the database"
puts "display - Display a movie of your choice"
puts "delete - Delete a movie in the database"

choice = gets.chomp

case choice
when "add" 
  puts "Enter the movie title to be added:"
  title = gets.chomp
  if movies[title.to_sym].nil?
  puts "What is the movie rating?"
  rating = gets.chomp
    movies[title.to_sym] = rating.to_i
  puts "Thank you! The pair has been added!"
  else puts "The movie already exists!"
when "update"
    puts "Updated!"
when "display"
    puts "Movies"
when "delete"
    puts "Deleted!"
    puts "Error!"


Perhaps a closer look at what the syntax is?

Also note that space isn't allowed in names, 17 Miracles is not a valid name.


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