spec: improve the example in Type assertions section
The example, var v, ok T1 = x.(T), can be interpreted as type T1 interface{} or type T = bool; type T1 = T. Separating the example would help understanding for readers. Change-Id: I179f4564e67f4d503815d29307df2cebb50c82f9 GitHub-Last-Rev: b34fffb6bb07cb2883bc313ef3bc9980b3dd4abe GitHub-Pull-Request: golang/go#44040 Reviewed-on: https://go-review.googlesource.com/c/go/+/288472 Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
98f8454a73
commit
fca94ab3ab
@ -1,6 +1,6 @@
|
|||||||
<!--{
|
<!--{
|
||||||
"Title": "The Go Programming Language Specification",
|
"Title": "The Go Programming Language Specification",
|
||||||
"Subtitle": "Version of Oct 7, 2020",
|
"Subtitle": "Version of Feb 2, 2021",
|
||||||
"Path": "/ref/spec"
|
"Path": "/ref/spec"
|
||||||
}-->
|
}-->
|
||||||
|
|
||||||
@ -3400,7 +3400,7 @@ A type assertion used in an <a href="#Assignments">assignment</a> or initializat
|
|||||||
v, ok = x.(T)
|
v, ok = x.(T)
|
||||||
v, ok := x.(T)
|
v, ok := x.(T)
|
||||||
var v, ok = x.(T)
|
var v, ok = x.(T)
|
||||||
var v, ok T1 = x.(T)
|
var v, ok interface{} = x.(T) // dynamic types of v and ok are T and bool
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user