Search code examples
haxe

Map types nesting issue


I'm trying to create this sort of Map:

var map:Map = new Map<Dynamic, Array<ProductData>>();

But compiler throws an error : Unexpected ; So it doesn't like the types declaration nesting. But I really do need that Array<ProductData> as a value of a map.

How can I overcome this mistake?


Solution

  • That's interesting, since I get a different error with that code:

    Invalid number of type parameters for Map

    That is fixed by removing the :Map though (just let type inference handle that).

    After that, though, I get the following error:

    Abstract Map has no @:to function that accepts IMap>

    ...or in other words - you can't have a Map with Dynamic keys in Haxe. Why are you using Dynamic there in the first place? Could that maybe be statically typed?