[ruby-talk:00282] Re: 'case' question

From: matz@... (Yukihiro Matsumoto)
Date: 1999-04-15 02:57:44 UTC
List: ruby-talk #282
Hi.

In message "[ruby-talk:00281] 'case' question"
    on 99/04/14, "bryce" <thecrow@cyberdude.com> writes:

|but this code, which I thought would be equivalent
|does not work.
|
|    case e.type
|        when BNClicked
|            print "\nGot BNClicked"
|    end
|
|Am I missing the reason why?

Because you should write this as:

>    case e
>        when BNClicked
>            print "\nGot BNClicked"
>    end


It's because case comparison is done by operator ===, which works as
`kind_of?' for classes and modules.
                                                matz.

In This Thread

Prev Next