CS 3304: Comparative Languages
Object-Oriented Programming
[
Course Documents
] : [
Object-Oriented Programming
]
Previous
Contents
Next
Keyword Index
Smalltalk Blocks
A sequence of statements, separated by periods, delimited by brackets
[index <- index + 1. sum <- sum + index]
A block specifies something, but doesn't do it
To request the execution of a block, send it the unary message, value
e.g., [...] value
If a block is assigned to a variable, it is evaluated by sending value to that variable
e.g.,
addIndex <- [sum <- sum + index] ... addIndex value