Why does this statement:-
private static var STAGE_TO_STACK : Dictionary = new Dictionary(true);
give me this compile error:-
Error:(42, 40) Invalid number of type parameters for flash.utils.Dictionary
Why does this statement:-
private static var STAGE_TO_STACK : Dictionary = new Dictionary(true);
give me this compile error:-
Error:(42, 40) Invalid number of type parameters for flash.utils.Dictionary
If you are using openfl’s Dictionary, it’s because Dictionary requires the type to be parameterized; you need to specify the “generic” arguments, which are called “type parameters” in Haxe.
In this case, Dictionary is defined as:
abstract Dictionary<K,V> (IMap<K, V>) {...}
which means that you have to provide the types for K and V, like so:
private static var STAGE_TO_STACK : Dictionary<Integer,String> = new Dictionary(true);
or:
private static var STAGE_TO_STACK : Dictionary = new Dictionary<Integer,String>(true);
or, the most specific (but unnecessarily wordy):
private static var STAGE_TO_STACK : Dictionary<Integer,String> = new Dictionary<Integer,String>(true);
Of course, you should change <Integer,String>
to match the types you need.
© 2018-2020 Haxe Foundation - Powered by Discourse