Go interface 详解 (四) :类型断言 | 三月沙
Opened this issue · 2 comments
utterances-bot commented
Go interface 详解 (四) :类型断言 | 三月沙
本系列是阅读 “The Go Programming Language” 理解和记录。 Type AssertionType assertion(断言)是用于 interface value 的一种操作,语法是 x.(T),x 是 interface type 的表达式,而 T 是 assertd type,被断言的类型。 断言的使用主要有两种情景: 如果 asserted type 是一个
rockyhwang commented
case 1 and case 2 have the same result as follows:
hello Go!*os.File
*os.File
The result is different from your statement above. Please double check. Thanks a lot!
zhyq0826 commented
@rockyhwang 输出的值一样,但是 case 2 中 rw 仍然是一个 interface,%T 确实只输出了实际的 dynamic type 的 value