SelectCase

Damien Cassou damien.cassou at laposte.net
Mon Jan 2 14:50:20 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

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.

The first one is used for the test (it defaults to [:ref :case | ref =
case]).

#default: is used when you don't know all the possible cases.

The project is called SelectCase
http://www.squeaksource.com/SelectCase/

Bye

- --
Damien
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDuT2s3hhx1vOEX5sRAh3BAJ9vGDaiE/yXDGblOa2f2sQZTaRG0ACfeQA+
EDx5Naz6pMNOHfYEnyEHhNg=
=p2LS
-----END PGP SIGNATURE-----



More information about the Squeak-dev mailing list