3. The Case Statement Error!



It gives me the correct message, but here's what I get in the console

movies = {
    Undertale: 10,
    Tem: 10,
    Puntale: 10,

choice = puts gets.chomp
case choice
    when "add"
        puts "Added!"
    when "update"
        puts "Updated!"
    when "display"
        puts "Movies!"
    when "delete"
        puts "Deleted!"
    puts "Error!"


Check this line:


Whats wrong with it? I just don't see a problem


@cssplayer82860 There is an extra comma


I just removed it, still says error


@cssplayer82860, Check the first letters of all your movies, they must not be titled


So they shouldn't be Uppercased? I just lowercased them now, still error. Please tell me every single thing i need to do.


You are writing
choice = puts gets.chomp

puts gets.chomp is a command that tells ruby to print what you type in. It's hard to make an analogy here, so I won't.

You are making a variable equal to a command to print something. What you want is the variable to equal what you actually type in

"choice = gets.chomp" should make choice equal to the string you are writing, and not the command to print the string you are writing.

What you are seeing is because you have typed in:

Then the system follows the puts command and prints what you typed in:

Then the program evaluates the variable you have entered for choice which is not "add" but is "please print 'add'", which most closely fits the else statement in your code and will puts:

Then, because I'm new to ruby and don't quite understand, it usually appends:


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