One response to “Enum toArray()”

  1. Eric Feminella

    What’s up Ken. Interesting post and a much better solution than what you might typically see; an additional Array of values redundantly mirroring those of the constants, in which case should America happen to acquire another state (like Canada – just kidding) and the Array is not updated then everything would be out of sync. Good example of adhering to the DRY principle.

    One suggestion I would make would be to cache the Array so as to avoid the expensive overhead of invoking describeType(); for all subsequent calls.

Leave a Reply