|
When Objective-C advocates say that the language is the addtion of Smalltalk-style objects to the C language, they mean it. In smalltalk square braces create a code block that can be passed around or called.
For example, the chunk of code below will ask object a to compare itself to b and return a True or False object repending on the result. The Boolean object will be sent the ifTrue: message with a block as the argument. The booleans that are instatiated from the 'True' class will execute the block, ones from 'False' will ignore it.
( a > b ) ifTrue:
[ Transcript show: 'a is bigger than b'. ]
|