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
end
and
case item.class
when MyClass.class
# do something here
when Array.class
# do something different here
when String.class
# do a third thing
end
For some reason, the first one of these works sometimes and the second doesn't, and other times, the second one works and the first one doesn't. Why? Which one is the "proper" way to do it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…