+ 3
I have found a bug in the Playground in Ruby.
This error is present both on the web interface and in the mobile application on Android. It is an example of the bug in a small program with my detailed comments: https://code.sololearn.com/cuVs0fN1sf8m I do not know how to report it to the developers.
6 Answers
+ 11
@Dennis and @Mickel pointed out that there is not a bug. But next time if you do find one, you can email Sololearn at info@sololearn.com or tell them via the feedback option đ
+ 5
There is no bug, gets includes a newline.
+\n is not equal to + so of course the switch won't work.
Use gets.chomp to drop said newline and it works fine.
+ 5
Dennis is right. In any case, there is another thing you should know. Your case statements work because they are not equivalent to an if statement
case myBar
when 1
some code
when 2
some code
It is equivalent to:
# if var == value is different from if var === value
if myBar === 1
some code
elsif myBar === 2
some code
end
Here you have more information:
https://blog.arkency.com/the-equals-equals-equals-case-equality-operator-in-ruby/
+ 4
Tap on the three dots on the top right of the screen, tap feedback, change it to bugs, and send it.
+ 2
Thanks for all! The gets.chomp method works fine.
+ 1
The issue is that there is a trailing newline character when getting user input. Use the strip function to remove the trailing white space.