Under Review
over 2 years ago

enum with no integer and no error

enum
{
    __1 = "test",
    __2,
    __3 = 0
}

println in console:

test
0
0

but according to doc https://developer.garmin.com/connect-iq/monkey-c/functions/

Note that assigning anything other than an integer will cause an error.

Parents
  • Possibly, if you look at the beginning of the wiki page you'll see:

    In computer programming, an enumerated type (also called enumerationenum, or factor in the R programming language, and a categorical variable in statistics) is a data type consisting of a set of named values called elementsmembersenumeral, or enumerators of the type

    If you look at enumeration on wikipedia, you'll see:

    An enumeration is a complete, ordered listing of all the items in a collection. The term is commonly used in mathematics and computer science to refer to a listing of all of the elements of a set.

    Elements in a set are not integers by definition. It can be anything in that set.

    In any case, I don't think strings should be dropped from being used in enums, but rather, the documentation should be updated. 

Comment
  • Possibly, if you look at the beginning of the wiki page you'll see:

    In computer programming, an enumerated type (also called enumerationenum, or factor in the R programming language, and a categorical variable in statistics) is a data type consisting of a set of named values called elementsmembersenumeral, or enumerators of the type

    If you look at enumeration on wikipedia, you'll see:

    An enumeration is a complete, ordered listing of all the items in a collection. The term is commonly used in mathematics and computer science to refer to a listing of all of the elements of a set.

    Elements in a set are not integers by definition. It can be anything in that set.

    In any case, I don't think strings should be dropped from being used in enums, but rather, the documentation should be updated. 

Children
No Data