dev/smalltalk/helloworld/collections.st

9 lines
352 B
Smalltalk
Raw Normal View History

2014-03-25 18:26:55 +04:00
a := #(1 'hi' 3.14 1 2 (4 5))
(a at: 3) displayNl "3.14"
(a reverse) displayNl "((4 5) 2 1 3.14 'hi' 1)"
(a asSet) displayNl "Set(1 'hi' 3.14 2 (4 5))"
.
hash := Dictionary from: { 'water' -> 'wet'. 'fire' -> 'hot' }.
hash at: 'fire' displayNl. "Prints: hot"
hash keysAndValuesDo: [ :k :v | ('%1 is %2' % { k. v }) displayNl ].