Minor addition to if-else text on declarations (#450)
* Minor addition to if-else text on declarations Extremely minor addition to if-else text on declarations preceding conditionals, by explicitly clarifying that variables declared are only available in branches succeeding the declaration, not all the branches in the if-else ladder (i.e. preceding branches will not have it in their scope) This edit might be redundant since variables in Golang can only be used after declaration, but to a complete novice the original wording of "...any variables declared in this statement are available in *all* branches..." might be a little misleading and appear to say that the variable is in-scope for the preceding branches as well (as this seems to be a very Golang-specific semantic that other high-level languages like C/C++, Java, Scala, Kotlin etc don't support; and so it will be a brand new paradigm for developers coming from such languages). Thanks! * Increment: Include changes in source .go file for #450
This commit is contained in:
parent
4f668ee955
commit
9ba0fd08de
@ -20,8 +20,8 @@ func main() {
|
||||
}
|
||||
|
||||
// A statement can precede conditionals; any variables
|
||||
// declared in this statement are available in all
|
||||
// branches.
|
||||
// declared in this statement are available in the current
|
||||
// and all the succeeding branches.
|
||||
if num := 9; num < 0 {
|
||||
fmt.Println(num, "is negative")
|
||||
} else if num < 10 {
|
||||
|
@ -1,2 +1,2 @@
|
||||
ae7f289ac1b2b1f152cd1952b93769209eed8e1d
|
||||
QlMkcwHvmns
|
||||
bbac731541876062076e3dea9a2b536988d7739d
|
||||
_5PfTs6dNhr
|
||||
|
6
public/if-else
generated
6
public/if-else
generated
@ -42,7 +42,7 @@ straight-forward.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="https://go.dev/play/p/QlMkcwHvmns"><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/_5PfTs6dNhr"><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>
|
||||
</td>
|
||||
@ -105,8 +105,8 @@ straight-forward.</p>
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>A statement can precede conditionals; any variables
|
||||
declared in this statement are available in all
|
||||
branches.</p>
|
||||
declared in this statement are available in the current
|
||||
and all the succeeding branches.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
|
Loading…
x
Reference in New Issue
Block a user