extended Collection with asOrderedCollection
This commit is contained in:
parent
fdda5c94f3
commit
04e28e979a
@ -722,6 +722,7 @@ class OrderedCollection(SequenceableCollection)
|
||||
} *)
|
||||
}
|
||||
|
||||
|
||||
## -------------------------------------------------------------------------------
|
||||
|
||||
class Set(Collection)
|
||||
@ -1543,3 +1544,17 @@ class LinkedList(Collection)
|
||||
^Error.Code.ENOENT
|
||||
}
|
||||
}
|
||||
|
||||
extend Collection
|
||||
{
|
||||
## ===================================================================
|
||||
## CONVERSION
|
||||
## ===================================================================
|
||||
method asOrderedCollection
|
||||
{
|
||||
| coll |
|
||||
coll := OrderedCollection new: self size.
|
||||
self do: [:each | coll addLast: each ].
|
||||
^coll
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,19 @@ extend MyObject
|
||||
[ (-9p10.123 scale) = (-10.123000000 scale) ],
|
||||
[ (+3p100.1 + 16rffff + +5p1.22 + -5p1.223) = 65635.09700 ],
|
||||
|
||||
## 80-84
|
||||
[ (30p2123.12 asString) = '2123.120000000000000000000000000000' ],
|
||||
[ (+30p2123.12 asString) = '2123.120000000000000000000000000000' ],
|
||||
[ (-30p2123.12 asString) = '-2123.120000000000000000000000000000' ],
|
||||
|
||||
## =========================
|
||||
[
|
||||
| k |
|
||||
k := String new.
|
||||
(%( 1 + 2, -21391239218392 * +291382913821, 19p10 div: 3 ) asOrderedCollection) doWithIndex: [:each :index | k := k & (index asString) & '=>' & (each asString) & ' '. ].
|
||||
k = '0=>3 1=>-6233041613697111534195832 2=>3.3333333333333333333 '.
|
||||
],
|
||||
|
||||
[
|
||||
| b |
|
||||
b := [:n | (n > 0) ifTrue: [ n * (b value: n - 1)] ifFalse: [1]].
|
||||
|
Loading…
Reference in New Issue
Block a user