remove(0,0) results in out of range error
AntonBogun opened this issue · comments
let l=[]
l.remove(0,0)
print(l)
results in VM error: remove: index (0) or n (1) out of range (0)
, while it should do nothing.
0
is actually a default value such that if you leave it out, it removes just 1 element.
I should allow it to use other values as defaults, that would fix this.
This should fix it.. 780df79
It actually improves default arg handling for builtin functions generally.
Actually, I was trying to support 0
for the amount to remove, but that can't work since its intended to return the first thing it removes: 8071024
Maybe should add a del() which is same as remove() but without returning the values?
Just so removing 0 elements becomes valid? I understand that's nice for genericity, but it seems OTT to add another function just for that edge case.
If anything, I could separate out remove
into 2 overloads: one arg that returns something, and 2 args (range) that returns nothing.
Sounds like a good idea
The version with a size parameter is now called remove_range
: 8654eab
Implementation is streamlined too.