links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Using curly braces
Last updated at 3:26 pm UTC on 13 October 2003
You can use curly braces in Squeak to construct runtime-evaluated collections. Tim Olson
[Updated (Dan I): brace expressions can no longer be used on the left of an assignment]

Curly braces are now used in Squeak to construct runtime-evaluated collections. For those of you who may not have seen it, Squeak lets you do the following:

1) Runtime-evaluated Collection Brace stacks can be used to create runtime-evaluated arrays almost as easily as literal arrays:

     {a. b-3. c squared}

     is equivalent to:

     Array with: a with: b-3 with: c squared

     except that a brace expression can be arbitrarily large without exceeding available with:with:... messages, and without exceeding available stack size.

     Any type of collection can be used by adding an as: message:

     {a. b-3. c squared} as: OrderedCollection

2) caseOf: statements

Another use of curly braces is to build a runtime collection of block associations for caseOf: statements:

     stateMachineState caseOf:
{ [1] -> [(firstByte << 2) bitOr: (secondByte >> 6)].
[2] -> [(firstByte << 6) bitOr: (secondByte >> 2)]}.

Fix Documentation