What is the Nim equivalence of List.Clear
in languages like java or c# for sequences? I see listed in system the proc setLen
, but im not sure it does what i want. From the description:
f the current length is greater than the new length, s will be truncated. s
Does it mean everytime i set any seq len to 0 it will create a new instance of seq?
setLen
resizes the seq
without allocating a new one, so usually x.setLen(0)
is fine. If you want to allocate a new seq
and let the garbage collector clean up the old one, you can do x = @[]
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With