12 lines
399 B
Smalltalk
12 lines
399 B
Smalltalk
accessing
|
|
optionsFromDictionary: aDictionary
|
|
|
|
aDictionary doWithIndex: [ :opt :i |
|
|
| key value prevKey |
|
|
i = 1
|
|
ifTrue: [ key := 1 to: (opt at: 'Chance') asInteger ]
|
|
ifFalse: [
|
|
prevKey := (aDictionary at: i - 1) at: 'Chance'.
|
|
key := prevKey asInteger + 1 to: (opt at: 'Chance') asInteger ].
|
|
value := (opt copy removeKey: 'Chance'; yourself).
|
|
self options at: key put: value ] |