当你把一个变量赋值给另一个变量时会发生什么?
- 变量们变成同一个
- 被赋值的变量被删除
- 变量的值被改变为赋值变量的值 正确
哪个是正确的赋值语句?
opened := true
closed := trueopened = false正确var x = 2
哪个是正确的赋值语句?
a, b = 3; 5c, d = true, false正确a, b, c = 5, 3
哪个是正确的赋值语句?
var (
n = 3
m int
)
m = "4"n = 10正确n = truem = false
哪个是正确的赋值语句?
var (
n = 3
m int
f float64
)
// one of the assignments below will be here
fmt.Println(n, m, f)
n, m = 4, fn = falsen, m, f = m + n, n + 5, 0.5正确n, m = 3.82, "hi"
哪个是正确的赋值语句?
var (
a int
c bool
)
a = _c, _ = _, false_, _ = a, c正确
哪个是正确的赋值语句?
记住: path.Split 返回两个 string 值
var c, f string
_ = path.Split("assets/profile.png")_, _, c = path.Split("assets/profile.png")f = path.Split("assets/profile.png")_, f = path.Split("assets/profile.png")正确