Integer evaluation with 'case' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Integer evaluation with 'case'

Hello. I'm having a hard time trying to understand what is wrong with the code and why it's doesn't work as I expect : https://code.sololearn.com/cBB87KVpV26u/#rb The variation without user input. Same result. https://code.sololearn.com/ccy1E1wFc65a/#rb But it works like magic when I wrap this into the method and call it with a parameter: https://code.sololearn.com/cGkef6WmrM1G/#rb Any help would be appreciated :)

25th Apr 2017, 5:03 PM
Arkadiy
4 Answers
+ 1
replace case n by n = case in the three examples and see what happens
26th Apr 2017, 3:52 AM
Ivan Taylor Hawkins
Ivan Taylor Hawkins - avatar
+ 1
Thanks, Ivan. I read almost all of these articles before. In most examples "case n" form is fine. I'm still not sure what is going on here and it is actualy a surprise for me that it works even with simple "case" word, without "n = " or "n". https://code.sololearn.com/cXJ5l2kkulDR/#rb I rewrite the code a little. It looks better this way or not? https://code.sololearn.com/cFizjf9s5831/#rb
26th Apr 2017, 6:44 AM
Arkadiy
0
Arkadly, good for you! titanic work!
26th Apr 2017, 2:00 PM
Ivan Taylor Hawkins
Ivan Taylor Hawkins - avatar