|
In particular the Array>>atWrap: version deserves love.
SequenceableCollection>>atWrap: index "Answer the index'th element of the receiver. If index is out of bounds, let it wrap around from the end to the beginning until it is in bounds." "(#(11 22 33) asOrderedCollection atWrap: 2) >>> 22" "(#(11 22 33) asOrderedCollection atWrap: 4) >>> 11" "(#(11 22 33) asOrderedCollection atWrap: 5) >>> 22"
^ self at: index - 1 \\ self size + 1
Array>>atWrap: index "Answer the index'th element of the receiver. If index is out of bounds, let it wrap around from the end to the beginning until it is in bounds."
"Optimized to go through the primitive if possible"
"(#(11 22 33) atWrap: 3) >>> 33" "(#(11 22 33) atWrap: 2) >>> 22" "(#(11 22 33) atWrap: 4) >>> 11"
<primitive: 60> ^ self at: index - 1 \\ self size + 1
|
|
|
Priority: 5 – Fix If Time
|
|
Status: Work Needed
|
|
Assigned to: Everyone
|
|
Milestone: Later
|
Go to Case
|
|