In ruby, I m using here class instead of age , it is showing syntax error, why?please help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

In ruby, I m using here class instead of age , it is showing syntax error, why?please help

class = 12 case class when 1,4,7 puts "primary students" when 5,9,11 puts "secondary students" else puts "professionals" end https://www.sololearn.com/discuss/2107118/?ref=app

22nd Dec 2019, 6:40 AM
Snehil Sparsh
Snehil Sparsh - avatar
2 Answers
0
Because "class" is a reserved word. Just like any other reserved word, you can't use it as a variable. Instead, use for example "age". Then your program will be fine.
22nd Dec 2019, 9:51 AM
molang
molang - avatar
0
Thanks
23rd Dec 2019, 5:29 AM
Snehil Sparsh
Snehil Sparsh - avatar