words.Split(“,”[0]) or the like and
Regex.Split() seems to return a builtinarray which needs to be converted back into a javascript array to use RemoveAt. But the MSDN .net docs claim that RemoveAt is available for Arrays. So I have no idea why I have to do this.
Eric? Dreamora?
Want to explain.
Why can’t unityscript implement a full javascript. I could avoid 90 percent of these problems.
The problem is that this code does not have an array. You are just using strings.
To do what I think you want to do:
var words = "here are the words removeme";
var wordlist = new Array();
wordlist = words.Split(" "[0]);
print(wordlist);
wordlist.RemoveAt(4);
print(wordlist);
var words = "here are the words removeme";
var wordlist = new Array();
wordlist = words.Split(" "[0]);
print(wordlist);
wordlist.RemoveAt(4);
print(wordlist);
if you leave out this line
var wordlist=new Array();
it does not work.
If you put it in
both Regex.Split and the other split type work. So there is something about that line that is making it work. Maybe it is typecasting the array from built in to javascript.
…the built-in array returned by the Split function get converted into a JS array automatically. If you assign the Split function’s result directly to a variable, its type gets set to a built-in array. The JS array can vary its length and has a RemoveAt function. The built-in array is of fixed length and has no such function.