test commmit
parent
ef4f411481
commit
b4fe567f2d
|
|
@ -80,6 +80,7 @@ There are three kinds of way to initialize variables:
|
||||||
var v1 int = 10 // method 1
|
var v1 int = 10 // method 1
|
||||||
var v2 = 10 // method 2
|
var v2 = 10 // method 2
|
||||||
v3 := 10 // method 3
|
v3 := 10 // method 3
|
||||||
|
v4 := [3]int{1, 2, 3} //initialize a slice
|
||||||
```
|
```
|
||||||
|
|
||||||
It can be observed that complier can deduce the data type automatically. However, when we use **method 3**, the variable should not be declared before, which will contibute to the error.
|
It can be observed that complier can deduce the data type automatically. However, when we use **method 3**, the variable should not be declared before, which will contibute to the error.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user