up till 08/01/2025
This commit is contained in:
1 parent
f39c523d4e
commit
3c12255382
2 files changed
+8
-19
No files matched your search
+4
-10
@@ -3,15 +3,9 @@ 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
|
||||
slice := []int{}
|
||||
for i := range slice {
|
||||
fmt.Println(i)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user