What is the equivalent of switch case (or case expr of) in Slate?

Lee Salzman lsalzman1 at cox.net
Fri Apr 1 16:55:27 PST 2005


evt TypeEvt caseOf:
  {SDL KEYDOWN -> [et showKeyDown: evt].
    SDL KEYUP -> [et showKeyUp: evt].
    SDL MOUSEBUTTONDOWN -> [et showClick: evt].
    SDL MOUSEMOTION -> [et showMouseMove: evt]
  } otherwise: [et showOther: evt].

Paul Dufresne wrote:

>In my SDL event looking code, I am doing:
>  SDL waitEvent: evt.
>  evt_type: evt TypeEvt.
>  evt_type == SDL KEYDOWN ifTrue: [et showKeyDown: evt ].
>  evt_type == SDL KEYUP   ifTrue: [et showKeyUp: evt ].
>  evt_type == SDL MOUSEBUTTONDOWN ifTrue: [et showClick: evt ].
>  evt_type == SDL MOUSEMOTION ifTrue: [et showMouseMove: evt ].
>  "I'd like to call showOther if it is none of the previous, but..."
>
>but I would have to make an if different than SDL KEYDOWN, and different
>than SDL KEYUP and differnt than ...
>
>That seems to long.
>What would be a better way to do this?
>Hope this is not in the manual.
>
>--Paul
>
>
>  
>




More information about the Slate mailing list