mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 00:43:26 +08:00
@@ -113,9 +113,9 @@ type Interval struct {
|
||||
初始化方式:
|
||||
|
||||
```go
|
||||
intr := Interval(0, 3) (A)
|
||||
intr := Interval(end:5, start:1) (B)
|
||||
intr := Interval(end:5) (C)
|
||||
intr := Interval{0, 3} (A)
|
||||
intr := Interval{end:5, start:1} (B)
|
||||
intr := Interval{end:5} (C)
|
||||
```
|
||||
|
||||
在(A)中,值必须以字段在结构体定义时的顺序给出,**&** 不是必须的。(B)显示了另一种方式,字段名加一个冒号放在值的前面,这种情况下值的顺序不必一致,并且某些字段还可以被忽略掉,就像(C)中那样。
|
||||
|
Reference in New Issue
Block a user