8

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?

braX
  • 11,506
  • 5
  • 20
  • 33
Arrrrrrr
  • 802
  • 6
  • 13

1 Answers1

12

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.

def-
  • 5,275
  • 20
  • 18