Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleExample - 'Variable hiding' is not allowed


Code Block
consume {
   if (true) {
      int myVar; //myVar will only be valid within this block
   } myVar = 2; //illegal! myVar does not exist here
   if (true) {
      int myVar; //myVar can be declared again as it is in a separate scope from above
   }
   int myVar; //ok! since it is a separate scope from above
}


For the built-in function block variables, such as the input variable in the consume block, ‘Variable hiding’ is allowed.

Final Variables

To prevent variables from being changed, the final keyword is used:

...