5. Scope of variables #

Created Tuesday 22 October 2019

The following cases show all possible outcomes of a scope error:

  1. Variable are accessible only within their nearest container codeblock.
  2. init Variable in for loop are in scope inside the braces. Similarly for while, **switch **statements.
  3. Overriding of value: if a variable in declared in the same scope, then this is an invalid practice.
  4. Overriding of value: if a variable is declared in an **inner **scope, with the same name as a variable from an **outer **scope, then the outer variable is lost, i.e the **inner **one shadows the **outer **one.