Added more information about shorthand variable declaration (#457)
This commit is contained in:
parent
30a235b655
commit
4944c3bc7b
@ -29,6 +29,7 @@ func main() {
|
|||||||
// The `:=` syntax is shorthand for declaring and
|
// The `:=` syntax is shorthand for declaring and
|
||||||
// initializing a variable, e.g. for
|
// initializing a variable, e.g. for
|
||||||
// `var f string = "apple"` in this case.
|
// `var f string = "apple"` in this case.
|
||||||
|
// This syntax is only available inside functions.
|
||||||
f := "apple"
|
f := "apple"
|
||||||
fmt.Println(f)
|
fmt.Println(f)
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
736ce4018f275bb8d12e5232349bae93611506b2
|
9aeef52b289d7ad9b9ac79f129d4e49f956c60ef
|
||||||
iYyAIilyBRf
|
N5rWndIliJW
|
||||||
|
5
public/variables
generated
5
public/variables
generated
@ -43,7 +43,7 @@ calls.</p>
|
|||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
<a href="https://go.dev/play/p/iYyAIilyBRf"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
<a href="https://go.dev/play/p/N5rWndIliJW"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||||
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
<pre class="chroma"><span class="kn">package</span> <span class="nx">main</span>
|
||||||
</pre>
|
</pre>
|
||||||
</td>
|
</td>
|
||||||
@ -133,7 +133,8 @@ zero value for an <code>int</code> is <code>0</code>.</p>
|
|||||||
<td class="docs">
|
<td class="docs">
|
||||||
<p>The <code>:=</code> syntax is shorthand for declaring and
|
<p>The <code>:=</code> syntax is shorthand for declaring and
|
||||||
initializing a variable, e.g. for
|
initializing a variable, e.g. for
|
||||||
<code>var f string = "apple"</code> in this case.</p>
|
<code>var f string = "apple"</code> in this case.
|
||||||
|
This syntax is only available inside functions.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code">
|
<td class="code">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user