What is the difference between
case item.class
when MyClass
# do something here
when Array
# do something different here
when String
# do a third thing
Yeah, Nakilon is correct, you must know how the threequal === operator works on the object given in the when clause. In Ruby
case item
when MyClass
...
when Array
...
when String
...
is really
if MyClass === item
...
elsif Array === item
...
elsif String === item
...
Understand that case is calling a threequal method (MyClass.===(item) for example), and that method can be defined to do whatever you want, and then you can use the case statement with precisionw