prko
1
Hello,
The .put
method for the List
class returns an instance of the List class:
~list = List[10, 20, 30]
~list.put(0, 1)
However, the following methods for the List
class return an instance of the List class:
~list = List[10, 20, 30]
~list.clipPut(0, 1)
~list = List[10, 20, 30]
~list.wrapPut(0, 1)
~list = List[10, 20, 30]
~list.foldPut(0, 1)
I think these three methods are buggy. However, I ask this before making a PR to get exact information about it.
I agree with you – a put
style method should return the receiver, and not anything else.
clipPut { arg i, item; i = i.asInteger.clip(0, this.size - 1); ^array.put(i, item) }
wrapPut { arg i, item; i = i.asInteger.wrap(0, this.size - 1); ^array.put(i, item) }
foldPut { arg i, item; i = i.asInteger.fold(0, this.size - 1); ^array.put(i, item) }
The ^array
bit is where it goes wrong.
But actually I’m not sure why these don’t read much more simply:
clipPut { arg i, item; array.clipPut(i, item) }
wrapPut { arg i, item; array.wrapPut(i, item) }
foldPut { arg i, item; array.foldPut(i, item) }
hjh
prko
3
Your code snippet solves the problem. I hope you can open a PR with it…
(I have not tried to fix the problems yet, but my code will be more complex than yours. I think your solution is the best!)