Quoting constructs: Difference between revisions

Content added Content deleted
Line 453: Line 453:
Thus, the expression "someBoolean ifTrue:[ 'hello print' ]" will either evaluate the lambda or not, depending on the someBoolean receiver.
Thus, the expression "someBoolean ifTrue:[ 'hello print' ]" will either evaluate the lambda or not, depending on the someBoolean receiver.
Obviously, you can teach other objects on how to respond to "value" messages and then use them as if they where blocks.
Obviously, you can teach other objects on how to respond to "value" messages and then use them as if they where blocks.
Actually, the Object class also implements "value", so you can also write:
<lang smalltalk>a := someCondition ifTrue:10 ifFalse:20</lang>
which works because "Object value" simply returns the receiver.


In addition, some Smalltalk dialects implement additional syntax extensions.
In addition, some Smalltalk dialects implement additional syntax extensions.