Anonymous user
Loops/Nested: Difference between revisions
→{{header|Smalltalk}}
Line 1,653:
=={{header|Smalltalk}}==
Notice that the original answer (see below) was wrong.
original text: "Smalltalk has no ways of escaping from loops (single or nested), even if it is possible to extend its iteration capabilities in several ways. "▼
{{works with|Smalltalk/X}}
Line 1,695:
exitBlock := [:exitValue | ^ exitValue].
[true] whileTrue:[ self value:exitBlock ]</lang>
in the same spirit, exits could be added to many other loop constructs. However, this is really only very rarely needed in Smalltalk, because a ^(return) out of a block returns from the enclosing method
There
<lang smalltalk>|v result|
Line 1,714:
]
].
nil
] valueWithExit.
Line 1,732 ⟶ 1,733:
{{works with|GNU Smalltalk}}
▲
The following code implements a BiArray class with a method that allows iteration over the elements (by columns and then by rows) and execution of a block if a condition is true.
<lang smalltalk>"this simple implementation of a bidimensional array
|