mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
修改 type-switch 拼写错误 (#402)
This commit is contained in:
@@ -63,7 +63,7 @@ func main() {
|
|||||||
val has the value: &{Rob Pike 55}
|
val has the value: &{Rob Pike 55}
|
||||||
Type pointer to Person *main.Person
|
Type pointer to Person *main.Person
|
||||||
|
|
||||||
在上面的例子中,接口变量 `val` 被依次赋予一个 `int`,`string` 和 `Person` 实例的值,然后使用 `type-swtich` 来测试它的实际类型。每个 `interface {}` 变量在内存中占据两个字长:一个用来存储它包含的类型,另一个用来存储它包含的数据或者指向数据的指针。
|
在上面的例子中,接口变量 `val` 被依次赋予一个 `int`,`string` 和 `Person` 实例的值,然后使用 `type-switch` 来测试它的实际类型。每个 `interface {}` 变量在内存中占据两个字长:一个用来存储它包含的类型,另一个用来存储它包含的数据或者指向数据的指针。
|
||||||
|
|
||||||
示例 [emptyint_switch.go](examples/chapter_11/emptyint_switch.go) 说明了空接口在 `type-switch` 中联合 `lambda` 函数的用法:
|
示例 [emptyint_switch.go](examples/chapter_11/emptyint_switch.go) 说明了空接口在 `type-switch` 中联合 `lambda` 函数的用法:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user