How can I slice an array so it's empty?

BlitzMax Forums/BlitzMax Beginners Area/How can I slice an array so it's empty?

Grey Alien(Posted 2006) [#1]
So like I'm a bit noob with slicin' and I've seen this to grow an array:

Local out[]
out=out[..Len(out)+1]


So how can I reset out back to an "empty" array of no slots (in a memory leak safe way) please? Thanks.


simonh(Posted 2006) [#2]
out=out[..0]?


H&K(Posted 2006) [#3]
out:Int=New Int[0]

(Obviously the array out needs to already exist)


Grey Alien(Posted 2006) [#4]
so simonh, does yours work? I never tested it...
H&K fair enough, could shorted to New Int[] I believe?


ImaginaryHuman(Posted 2006) [#5]
out=Null?

or do you need it to still think an array is defined?


tonyg(Posted 2006) [#6]
so simonh, does yours work? I never tested it
You lazy git!
Local out[10]
Print Len(out)
out = out[..0]
Print Len(out)



Grey Alien(Posted 2006) [#7]
AngelD: yeah still need it to be an array.

You lazy git!
lol, I had to go an eat dinner when I saw Simon's solution. no time, so busy etc ;-)