mirror of
https://github.com/golang/go
synced 2024-11-25 01:57:56 -07:00
allow "comma ok" in initializers
DELTA=11 (4 added, 0 deleted, 7 changed) OCL=33698 CL=33712
This commit is contained in:
parent
28b655ea07
commit
d55370760f
@ -2160,12 +2160,13 @@ an otherwise legal index expression, a run-time exception occurs.
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
However, if an index expression on a map <code>a</code> of type <code>map[K] V</code>
|
However, if an index expression on a map <code>a</code> of type <code>map[K] V</code>
|
||||||
is used in an assignment of one of the special forms
|
is used in an assignment or initialization of the form
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
r, ok = a[x]
|
r, ok = a[x]
|
||||||
r, ok := a[x]
|
r, ok := a[x]
|
||||||
|
var r, ok = a[x]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2262,12 +2263,13 @@ is known only at run-time, the type of <code>x.(T)</code> is
|
|||||||
known to be <code>T</code> in a correct program.
|
known to be <code>T</code> in a correct program.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If a type assertion is used in an assignment of one of the special forms,
|
If a type assertion is used in an assignment or initialization of the form
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
v, ok = x.(T)
|
v, ok = x.(T)
|
||||||
v, ok := x.(T)
|
v, ok := x.(T)
|
||||||
|
var v, ok = x.(T)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -2851,11 +2853,13 @@ f(<-ch)
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
If a receive expression is used in a tuple assignment of the form
|
If a receive expression is used in an assignment or initialization of the form
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
x, ok = <-ch; // or: x, ok := <-ch
|
x, ok = <-ch
|
||||||
|
x, ok := <-ch
|
||||||
|
var x, ok = <-ch
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user