SelectCase

Damien Cassou damien.cassou at laposte.net
Wed Jan 4 12:37:17 UTC 2006


Andreas Raab wrote:

> Ragnar Hojland Espinosa wrote:
>
>>> I know select/case statements is not desired in the squeak community
>>> and I understand why (it's often a wrong modelisation). But I put
>>> an implementation in squeaksource which can be used like this :
>>>
>>> (aString selectCase )
>>>        testBlock: [:ref :case | case match: ref];
>>>        case: 't*' exec: [self assert: false];
>>>        case: 'v*' exec: [self assert: true];
>>>        case: 'value' exec: [self assert: false];
>>>        default: [^ nil]
>>>
>>> #testBlock: and #default: can be ommited.
>>
>>
>> What's wrong with
>> http://wiki.cs.uiuc.edu/CampSmalltalk/Smalltalk+case-statement ?
>
>
> Nothing. I think it sucks just about as much as the above ;-) And, oh, 
> did you know that Squeak has had a case statement for ages? I've never 
> seen it used in any code but, in theory, it works like this:
>
>     aString caseOf: {
>         ['foo'] -> [self foo].
>         ['bar'] -> [self bar].
>     } otherwise:[self frobler].


I developped this more as an exercise than for real use. I didn't search 
for other projects.



More information about the Squeak-dev mailing list