- Home /
Question by
Caiuse · Jul 15, 2011 at 10:02 AM ·
arraystypecasting
Typecast a Generic List in UnityScript
C#:
List< Transform> listOfTransform = new List< Transform>;
How can I type cast in JS in the same way?
Cheers - C
Comment
Note that
var listOfTransform = new List<Transform>;
is valid C# and results in listOfTransform being typed as List. That's called type inference, and has nothing to do with dynamic typing. The only difference with JS is that you need a ".", as shown in Warwick Allison's answer.
Answer by Waz · Jul 15, 2011 at 11:56 AM
That isn't type casting, but anyway, you can do this:
var listOfTransform : List.<Transform> = new List.<Transform>();
or simply:
var listOfTransform = List.<Transform>();
Your answer
Follow this Question
Related Questions
Maximum elements in a Generic List 0 Answers
Type casting error while instantiating. 1 Answer
Dynamic array length problem.Why my code generate error? 1 Answer
Casting arrays in js 3 Answers