Category:Smalltalk: Difference between revisions

Line 367:
====Block Arguments and Locals====
This are visible inside a block and all of its enclosed blocks. Args are specified by listing them prefixed by a colon, following a vertical bar, followed by optional local variables:
<lang smalltalk>[:arg | ... block's code here...]. "a one-arg block"
[:a1 :a2 :a3 | ... ] "a three-arg block"
[ |local1 local2| ... ] "a no-arg block with 2 locals"
[:a :b :c | | l1 l2 l3 | "3 args (a,b,c) and three locals (l1,l2,l3)"</lang>
Blocks can be nested, and inner blocks can refer to any statically visible outer scope's variable.
 
====Pool Dictionaries====
Are additional namespaces (name-value bindings), which are explicitly "imported" to make all their bindings visible. Used to share constants or singletons (or even classes) between cooperating classes, which are not inheriting from a common superclass.
Anonymous user