Suggestion for enums

Topics: Language Specification
Nov 17, 2012 at 3:01 PM
Edited Nov 17, 2012 at 3:02 PM

It would be great if enums still acted as numbers for arithmetic and bitwise operators, but could also be toString'ed correctly.

That could be done by creating a class for an enum, and overriding valueOf and toString.

Also the name of an enum should be possible to use as a converter function from number to the enum (similar to Number("12")).

 

Creating classes for enums might sound non-performant, but actually there could only be a small number of values per enum.

Coordinator
Nov 20, 2012 at 3:15 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.