initialise
This commit is contained in:
17
test/main.go
Normal file
17
test/main.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// Initialize the variable before the loop
|
||||
value := 0
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
// Change its value within the loop
|
||||
value += i
|
||||
fmt.Println("Current Value:", value) // Use the variable here
|
||||
}
|
||||
|
||||
fmt.Println("Final Value:", value) // Still accessible after the loop
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user