Created
September 23, 2024 15:25
-
-
Save biancarosa/5439630f23cb7d18d2588e36f620704e to your computer and use it in GitHub Desktop.
Entenda o Escopo do seu Código
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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