-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Is your feature request related to a problem? Please describe.
I want to call a method from within the constructor. For this the method must be declared as static. Within the method I want to set a variable and so the variable must also be declared static. See example code below.
service SomeExampleService {
static Boolean running = False;
construct() {
runSomething();
}
static void runSomething() {
// just to be on the safe side in case it would run super long
if (!running) {
running = True;
// do lots of stuff here
running = False;
}
}
}
The compiler complains with:
COMPILER-70: The expression cannot be assigned to. ("running")
After talking to Gene and Cam they explained that static in this context also means final.
Describe the solution you'd like
Display a better error message why a value can't be assigned to a static variable. Any new devs coming from Java will very likely encounter the same problem and scratch their heads.
"The expression cannot be assigned to. ("running"). static makes the property final. Use a singleton service instead."
Describe alternatives you've considered
n/a
Additional context
n/a