How do I unsubscribe from this list...The message flow is nuts...I have
sent multiple messages to the controller address
<ruby-core-ctl / ruby-lang.org>, and <ruby-core-ctl / ruby-lang.org> with
unsubscribe in the body...Can you pull my name from the list...Thanks
Jeff

 

On Mon, 2002-10-28 at 06:29, Kent Dahl wrote:
> Khurram wrote:
> > 
> > Hi all,
> > 
> > I was trying to develop a definition for the  === operator on a custom
> > class I made.  It seems like that when I use case statements on an
> > object of the class the === operator does not get invoked.  What could
> > I be doing wrong?
> > Here's how I'm using it.
> > 
> > a = MyClass.new()
> > 
> > case a
> > when 'hello';printf "Blah....\n"
> > when 'bye' ; printf "Blah....Blah...\n"
> > else; printf "Blah... Blah... Blah...\n"
> > end
> > 
> > I know I have the === operator correctly defined.. Because when I
> > explicitly use it as follows then it works:
> > 
> >      if a === 'hello'
> >         printf "Blah....\n"
> >      elsif a === 'bye'
> >         printf "Blah....Blah...\n"
> >      else
> >         printf "Blah... Blah... Blah...\n"
> >      end
> > 
> > Any clues on what I'm doing wrong?
> 
> The case operator flips the order here.
> "case a; when b ;...; end" equals "if b===a then ... end"
> 
> class A
>   def ===(o)
>     puts "#{self.type.to_s} === #{o.type}"
>   end
> end
> 
> a = A.new
> s = "Hello"
> case s
> when a #=> A === String
> end
> 
> -- 
> (\[ Kent Dahl ]/)_    _~_    __[ http://www.stud.ntnu.no/~kentda/ ]___/~
>  ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 5. year  )
> ( \__\_|_/__/ ) _)Industrial economics and technological management(
>  \____/__\____/ (____engineering.discipline_=_Computer::Technology___)