Clear Array?
BlitzMax Forums/BlitzMax Beginners Area/Clear Array?
| ||
I'm trying to figure out how to clear an array. I'm currently using an array in a type. See below example:Type TtextFile defaults:TMap lines:String[] filePath:String ... ... Method Clear() filePath="" 'Clear the file path defaults.clear() 'Clear the defaults map lines=New String[] 'Hmmm... How to clear the lines[] array? End Method End Type |
| ||
For ct:int=0 to lines.length-1 lines[ct]="" next |
| ||
If you want the array to stay the same size, dolines = New String[lines.Length] If you want a new, empty array do lines = New String[0] |
| ||
aah ok, that makes sense thanks guys |
| ||
I wonder whats faster.. the Malloc for the new array or just clearing the contents of an existing one... hmmm |
| ||
A lot of people want to clear their arrays recently, is it spring-cleaning time :D |