What is the best way to use a class object in case statement? Suppose I have a
which is an instance of the Class
class. I want to match it against different classes. If I do
case a
when String then ...
when Fixnum then ...
end
this will not give the intended result because even if a == String
for example, a === String
is not true. What is the clever way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…