mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:11:49 +08:00
update book code
This commit is contained in:
32
eBook/exercises/chapter_4/local_scope.go
Normal file → Executable file
32
eBook/exercises/chapter_4/local_scope.go
Normal file → Executable file
@@ -1,17 +1,17 @@
|
||||
package main
|
||||
|
||||
var a = "G" // global (package) scope
|
||||
|
||||
func main() {
|
||||
n()
|
||||
m()
|
||||
n()
|
||||
}
|
||||
func n() {
|
||||
print(a)
|
||||
}
|
||||
func m() {
|
||||
a := "O" // new local variable a is declared
|
||||
print(a)
|
||||
}
|
||||
package main
|
||||
|
||||
var a = "G" // global (package) scope
|
||||
|
||||
func main() {
|
||||
n()
|
||||
m()
|
||||
n()
|
||||
}
|
||||
func n() {
|
||||
print(a)
|
||||
}
|
||||
func m() {
|
||||
a := "O" // new local variable a is declared
|
||||
print(a)
|
||||
}
|
||||
// GOG
|
Reference in New Issue
Block a user