Manuscript (Case [Issue]22382) _Inbox - atWrap: and atWrap:put: should be better commented and have an executable comment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Manuscript (Case [Issue]22382) _Inbox - atWrap: and atWrap:put: should be better commented and have an executable comment

Pharo Issue Tracker
Manuscript Notification
avatar
Bug in Project:  _Inbox: Not Spam  •  You are subscribed to this case
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 Priority: 5 – Fix If Time Status Status: Work Needed
Assigned To Assigned to: Everyone Milestone Milestone: Later

Go to Case
No longer need updates? Unsubscribe from this case.

Don't want Manuscript notifications anymore? Update your preferences.

Manuscript

_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
https://lists.gforge.inria.fr/mailman/listinfo/pharo-bugtracker