Skip to content
CCPEDIAby Unity Nodes
App Development

Enum instance for Month is misleading

2 posts411 views5 likesLast activity Feb 2021

  1. Alexander_BernauerOP 1

    Hi,

    unless I am mistaken, toEnum 1 :: Month is not Jan, but Feb.

    Needless to say I fell into this trap. Now, I am not sure if it is too late to change this with a custom instance Enum Month. If it is, I propose a note about this in the documentation.

    Regards,
    Alex

  2. cocreature 4

    Hi @Alexander_Bernauer, I recommend viewing Enum not as a way to convert types from and to Ints but instead to view it purely as a way to enumerate values with the integer conversion being an implementation detail. At that point, it doesn’t matter whether toEnum returns 0, 23 or 42. If you need a specific integer conversion, you are better off implementing your own.

    That said, I fully agree, that are docs are lacking here and we’ll work on clarifying this.