Why is my code wrong? It displayed "Added!"


#1

At the 3.Case Statement
I have input the code and it executed correctly by displaying 'Added!' when the choice is 'add'. But it keeps saying my code does not do it. Can't figure out what is wrong.

print "Input your choice"
choice=gets.chomp!
case choice
when "add"
puts "Added!"
when ...

end


#2

@pyace62315,
1. Please give the FULL code you are using
2. Do not use the so-called bang operator ! with your chomp
3. Have you tried a refresh Browser

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


#3

Thanks for the reply.
This is at the course "A Night at the Movies"
Here is the full code. I have removed the bang, and it is reported the same.
I have reset the code, and it still reported the same.

The curious thing is that when I input "add", the run result already shows "Added!", but the course still refuse to admit the code.

Here is the code.

movies={speed:4, terminator:5}
print "Input choice: "
choice=gets.chomp
case choice
when 'add'
puts 'Added!'
when 'update'
puts 'Updated!'
when 'display'
puts 'Movies!'
when 'delete'
puts 'Deleted!'
else
puts 'Error!'
end

The result window shows:

Input choice: add
Added!
nil


#4

@pyace62315
Replace your

print  "Input choice:"

with a

puts "Input choice: "

#5

Thanks. It does the trick.