7. Update SCT Error


#1

https://www.codecademy.com/courses/learn-ruby/lessons/a-night-at-the-movies/exercises/update

I’m receiving an “SCT error” despite my code running smoothly. Unsure of how to proceed. Looking at previous topics on those who have gotten SCT errors, it seems that I may not have entered in the code exactly as the interpreter wanted it? I attempted to copy the section from the first lesson where it shows the completed code, however I received the same error.

Windows 7, Firefox 55.0 x64



movies = {
  platoon: 4
  }

def menu(movies)

puts "Enter Option:"
puts "--Add\n--Update\n--Display\n--Delete\n--Exit"
choice = gets.chomp
choice.downcase!


case choice
  when "add"
  	puts "What is the title of the movie you'd like to add?"
  	title = gets.chomp.downcase
  	if movies[title.to_sym] != nil
       puts "That movie is already rated"
      menu(movies)
    else
  	puts "What's the rating of that movie?"
  	rating = gets.chomp
  	movies[title.to_sym] = rating.to_i
  	movies.each {|title, rating| puts "#{title} is rated #{rating}"}
      menu(movies)
    end
  when "update"
  	puts "Which movie would you like to update?"
  	title = gets.chomp.downcase
  	if movies[title.to_sym] == nil
      puts "That movie is not in the database, yet."
      else 
      puts "What is the new rating?"
      rating = gets.chomp
      movies[title.to_sym] = rating.to_i 
    end
   menu(movies)
  when "display"
  	movies.each {|title, rating| puts "#{title} is rated #{rating}"}
   menu(movies)
  when "delete"
  	puts "Deleted!"
   menu(movies)
  when "exit"
  	puts "Thank you for using the movie database!"
  else
  	 menu(movies)
end

end
menu(movies)




#2

That is not in the instructions.


#3

Right, I didn’t want to rerun the code for each little test, so I set up a method and recursion to store the additions to the hash. If there’s no way around it, then I’ll follow the straight-shot way.


#4

For best results, stay as close to the instructions as possible. The SCT may have specific expectations.

We are free to experiment with the lesson code, notwithstanding that we complete the module, first.


#5

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