Jett
Digital Artist
Hi guys, let's say I have a function that accepts a string and a separator and I want to return a ds_list of substrings based on the separator. Like a explode() in php or split() in js.
You see I created a ds_list in
Thanks in advance
GML:
function stringExplode(str,sep) {
var length = 0;
var lastpos = 1;
var words = ds_list_create();
for (i=1; i<string_length(str)+1; i++) {
length ++;
if (string_char_at(str, i) == sep) {
ds_list_add(words, string_copy(str, lastpos, length));
length = 0;
lastpos = i+1;
} else if ( i == string_length(str)) {
ds_list_add(words, string_copy(str, lastpos, length));
}
}
return words;
}
var words = ds_list_create();
and I returned it after some loop stuff. How do I ds_list_destroy to the ds_list I created earlier when the function ends on return? Is it fine to just leave it like this? Do they just keep piling up in the memory everytime I execute this function? or do they get cleaned up automatically somehow? Thanks in advance