From: Jamis Buck Date: 2005-02-24T01:59:29+09:00 Subject: Re: surprising: class A; end; A === A ==> false On 01:24 Thu 24 Feb , Sam Roberts wrote: > I'm used to thinking of === being MORE useful > On thinking about it, I can see why: in A === A, A is of class Class, > and that class is not derived from the class A, so comparison is > false... > > But this causes me some trouble, because there is no way to use > case statements with a class: > > class A > Ordinal = 1 > end > class B > Ordinal = 2 > end > > t = A > > case t > when A then ... > when B then ... > end > > No case will ever match! > > Is my only way: > > if t == A > ... > elsif t == B > ... > elsif > ..... > > or is there some clever workaround? You could do: case t.name when "A" then ... when "B" then ... end or case t.id when A.id then ... when B.id then ... end Still kind of kludgy, though. - Jamis -- Jamis Buck jamis_buck@byu.edu http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."