Skip to content

Instantly share code, notes, and snippets.

@biancarosa
Created September 23, 2024 15:25
Show Gist options
  • Select an option

  • Save biancarosa/5439630f23cb7d18d2588e36f620704e to your computer and use it in GitHub Desktop.

Select an option

Save biancarosa/5439630f23cb7d18d2588e36f620704e to your computer and use it in GitHub Desktop.
Entenda o Escopo do seu Código
package main
import "fmt"
var x int
func anotherFunction() {
fmt.Println(x)
// fmt.Println(y) - não pode ser usado aqui :)
}
func main() {
var y int
x = 10
y = 10
fmt.Println("Qual o valor de x?", x) // 10
if x == y {
for x := 100; ; {
fmt.Println("Qual o valor de x?", x) // 100
if x == 100 {
break
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment