notexOPENOverview
Notex/Languages/Code Review: Blocks, shadowing, and if statements
02.03LESSON 03 OF 19 · 1 MIN READ

Code Review: Blocks, shadowing, and if statements

Always free to read
  • Watch for accidental shadowing when using := in inner scopes.

  • Do not give a local variable the same name as an imported package; this makes the package unreachable for the remainder of the enclosing block.

  • Never redefine an identifier from the universe block. The compiler may not catch it, and the resulting bugs are subtle.

  • If the variable being tested in the condition of an if statement is only useful within the if and else blocks, assign its value in the initialization section of the if statement so it is scoped to just the if and else blocks.

Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K