+ Start a Discussion

Using Map with Enum ?

So, I tried to use a map with an Enum object (which I am told I can use as a datatype in the documentation), but it does not work.



Declaration in the class definition:


public enum Season {WINTER, SPRING}


Definition of Map in the constructor:



Map<Season,String> heatMap = new Map<Season,String> ();








Error: Compile Error: Map by CustomCon.Season not allowed at line 27 column 37




I have experienced the same issue.  Does anyone know if there is a solution to this?  Clearly enums are not just another datatype if this doesn't work.


Does anyone have any work-arounds for such a scenario?




I'd be interested in an answer to this as well.