Logan Capaldo
8/9/2006 12:45:00 AM
On Aug 8, 2006, at 8:30 PM, richB wrote:
> # Sorry, very newbie question ...
>
> C:/> ruby -v
> ruby 1.8.2 (2004-12-25) [i386-mswin32]
>
> C:/> irb
> irb(main):001:0> a = 3.2
> => 3.2
> irb(main):002:0> puts "match" if a.class==Float
> match
> => nil
> irb(main):003:0> puts "match" if a.class===Float
> => nil
> irb(main):004:0>
>
> Why does '==' match, and '===' does not. I am trying to use a case
> statement on the class and it doesn't work because '===' is not giving
> the newbie expected result.
>
> Please don't hurt me. Thanks for your patience! - RichB
>
>
No one wants to hurt you my friend, in fact ruby has anticipated your
need:
a = 2.3
case a
when Float
...
end
end
p Float === 1.2