Variables
that are declared without initialization are assigned with zero values.
Zero value
a.
0
for numeric types,
b.
false
for the boolean type, and
c.
""
(the empty string) for strings.
App.go
package main import "fmt" func main() { var i int var f float64 var b bool var s string fmt.Println("i = ", i) fmt.Println("f = ", f) fmt.Println("b = ", b) fmt.Println("s = ", s) }
Output
i = 0
f = 0
b = false
s =
No comments:
Post a Comment