This question was
closed Sep 05, 2016 at 08:40 AM by
LexGear for the following reason:
The question is answered, right answer was accepted
Remove empty "" strings from array String[]
Hi Everyone. What is the BEST method for removing items from an array? I have a String[] variable, and I need to remove all the "" (empty lines from it).
var linesToCheck : String[];
var lines : String[];
linesToCheck = script.text.Split( '\n'[0] );
// Remove any empty lines from script
for ( var line in linesToCheck )
{
if ( line != "" )
lines.Add( line );
}
Comment
I just noticed I posted my erroring code. Obviously this doesn't work because Add is not a member of String[].
Best Answer
Answer by LexGear · Sep 05, 2016 at 08:39 AM
I just figured out the solution to my problem myself, which was to simply change my array type from "String[]" to "new Array();"