connectiqmonkeyc

Const keyword not recognized by MonkeyC


I am building project in monkeyc (ConnectIq) from Garmin in Eclipse, and I want to use const instead of var in my code, but it seems that the const keyword is not recognized by the compiler. What could be wrong?

My code is:

const PI = 3.14;

Compiler complain like this:

BUILD: ERROR: C:\Path:155  missing '}' at 'const'

If I change const to var, everything goes well. Where can be a problem? From Garmin documentation MonkeyC should haveconst keyword.


Solution

  • I realized that const keyword cannot be inside a function, it has to be as a class variable. Then it works. I just do not know if it is a bug or a feature.