4.2.1
How can I initialise a typed variable to an empty array?
The code: var new_walls : Array[Polygon2D] = Array() as Array[Polygon2D] complains that I can’t assign and Array to a variable of type Array[Polygon2D]
var new_walls : Array[Polygon2D] = Array() as Array[Polygon2D]
Array
Array[Polygon2D]
What is the correct magical syntax to do this?
This should work
var new_walls : Array[Polygon2D] = []
You have already declared the type with :Array[Polygon2D]
:Array[Polygon2D]
Oh, that’s so obvious in retrospect. I can’t believe I didn’t try it. Thanks.
It’s easy to miss the simple things sometimes.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.