4 * #(1 2 3) " => #(4 8 12) " (4 @ 5) * #(1 2 3) " => #(4@5 8@10 12@15) " '456' * #(1 2 3) " => #(456 912 1368) "
#(2 2 3 4 1 4 2 1 4) asBag " => a Bag(1 1 2 2 2 3 4 4 4) " #(2 2 3 4 1 4 2 1 4) asSet " => a Set(1 2 3 4) " #(2 2 3 4 1 4 2 1 4) asOrderedCollection " => an OrderedCollection(2 2 3 4 1 4 2 1 4) " #(2 2 3 4 1 4 2 1 4) asSortedCollection " => a SortedCollection(1 1 2 2 2 3 4 4 4) " 'smalltalk' asArray " => #($s $m $a $l $l $t $a $l $k) " 'smalltalk' asBag " => a Bag($k $l $l $l $m $a $a $s $t) " 'smalltalk' asSet " => a Set($k $l $m $a $s $t) " 'smalltalk' asOrderedCollection " => an OrderedCollection($s $m $a $l $l $t $a $l $k) " 'smalltalk' asSortedCollection " => a SortedCollection($a $a $k $l $l $l $m $s $t) "
| collection | collection _ OrderedCollection new. collection add: 3; add: 2; add: 2; add: 1. ^ collection " => an OrderedCollection(3 2 2 1) " | collection | collection _ Set new. collection add: 3; add: 2; add: 2; add: 1. ^ collection " => a Set(1 2 3) " "重複排除" | collection | collection _ SortedCollection new. collection add: 3; add: 2; add: 2; add: 1. ^ collection " => a SortedCollection(1 2 2 3) " "ソート済み"
Array new add: 3; add: 2; add: 2; add: 1 " => error "
| array | array _ Array new: 4. array at: 1 put: 3. array at: 2 put: 2. array at: 3 put: 2. array at: 4 put: 1. ^ array " => #(3 2 2 1) "
OrderedCollection with: 3 with: 2 with: 2 with: 1 " => an OrderedCollection(3 2 2 1) " Set with: 3 with: 2 with: 2 with: 1 " => a Set(1 2 3) "
Array with: 3 with: 2 with: 2 with: 1 " => #(3 2 2 1) " String with: $c with: $b with: $b with: $a " => 'cbba' "
OrderedCollection withAll: #(3 3 3 2 2 1 1 1 1) " => an OrderedCollection(3 3 3 2 2 1 1 1 1) " Set withAll: #(3 3 3 2 2 1 1 1 1) " => a Set(1 2 3) "
このページを編集 (4492 bytes)
以下の 1 ページから参照されています。 |
This page has been visited 842 times.