'From Squeak 2.5 of August 6, 1999 on 30 August 1999 at 2:02:03 pm'! !Array methodsFor: 'enumerating' stamp: 'mjg 8/30/1999 14:01'! switchOn: argument "Provide a case-like statement: #( ('a' [Transcript show: 'An a was input']) ('b' [Transcript show: 'A b was input'])) switchOn: 'a' The tricky part is that a literal array returns the block as individual string elements of the array. " | firstCouplet blockToEvaluate | firstCouplet := self at: 1. (argument = (firstCouplet at: 1)) ifTrue: ["Now we have to translate the rest of the block" "We ask the compiler to evaluate the string formed by concatenating the rest" blockToEvaluate := Compiler evaluate: (firstCouplet copyFrom: 2 to: firstCouplet size). blockToEvaluate value.] ifFalse: [(self allButFirst) switchOn: argument] ! !