Closed AntonBogun closed 2 years ago
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.. https://github.com/aardappel/lobster/commit/780df79b481181cde42133323dcf09aea96d2026 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: https://github.com/aardappel/lobster/commit/8071024d25b265a7534ecb69dc413f99a313143a
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
: https://github.com/aardappel/lobster/commit/8654eab9409f926834bfb830f5ea948077f76976
Implementation is streamlined too.
results in
VM error: remove: index (0) or n (1) out of range (0)
, while it should do nothing.