# Variables in functions have local scope

function sumPlusTwo(x, y)
  a = 2
  x + a + y
end

# println(a) # UndefVarError - a not defined outside its local scope
println(sumPlusTwo(1, 1))

# Loops have local scoped Variables
for i = 1:10
  a = 2
  m = a * i
  println("$a * $i = $m")
end

# UndefVarError for both of these
# println(a)
# println(m)

for i = 1:1
  a = 2
  println("Outer loop: a = $a")
  for i = 1:1
    a = 3
    local b = 1
    println("Inner loop a = $a")
    println("Inner loop b = $b")
  end
  println("Outer loop: a = $a")
  # println("Outer loop: b = $b") - b not defined here
end