S
Sonny Chee
Hey Guys,
Let me apologize upfront if this is not the appropriate place to ask
newbie questions. I can repost, if someone can point me to the correct
location.
Assuming no is offended, my question is:
I read that the case statement uses the === method for comparison of
each of its clauses. So, why doesn't the second comparison in the
following code snippet evaluate identically?
a_fix_num = 1
puts a_fix_num.class
case a_fix_num
when Integer
puts 'Yes, this is an Integer subclass'
else
puts 'No, this is not an Integer subclass'
end
if a_fix_num === Integer
puts 'Yes, this is an Integer subclass'
else
puts 'No, this is not an Integer subclass'
end
# Fixnum
# Yes, this is an Integer subclass.
# No, this is not an Integer subclass.
Sonny.
Let me apologize upfront if this is not the appropriate place to ask
newbie questions. I can repost, if someone can point me to the correct
location.
Assuming no is offended, my question is:
I read that the case statement uses the === method for comparison of
each of its clauses. So, why doesn't the second comparison in the
following code snippet evaluate identically?
a_fix_num = 1
puts a_fix_num.class
case a_fix_num
when Integer
puts 'Yes, this is an Integer subclass'
else
puts 'No, this is not an Integer subclass'
end
if a_fix_num === Integer
puts 'Yes, this is an Integer subclass'
else
puts 'No, this is not an Integer subclass'
end
# Fixnum
# Yes, this is an Integer subclass.
# No, this is not an Integer subclass.
Sonny.