From 9ba0fd08dec193255b32d0d925552c9232df3a4c Mon Sep 17 00:00:00 2001 From: Aditya Sood Date: Tue, 25 Oct 2022 18:30:36 +0530 Subject: [PATCH] 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 --- examples/if-else/if-else.go | 4 ++-- examples/if-else/if-else.hash | 4 ++-- public/if-else | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/if-else/if-else.go b/examples/if-else/if-else.go index 1f2a403..d326b90 100644 --- a/examples/if-else/if-else.go +++ b/examples/if-else/if-else.go @@ -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 { diff --git a/examples/if-else/if-else.hash b/examples/if-else/if-else.hash index 8f1ebb5..a0aa4b6 100644 --- a/examples/if-else/if-else.hash +++ b/examples/if-else/if-else.hash @@ -1,2 +1,2 @@ -ae7f289ac1b2b1f152cd1952b93769209eed8e1d -QlMkcwHvmns +bbac731541876062076e3dea9a2b536988d7739d +_5PfTs6dNhr diff --git a/public/if-else b/public/if-else index b05329e..1523e8d 100644 --- a/public/if-else +++ b/public/if-else @@ -42,7 +42,7 @@ straight-forward.

- +
package main
 
@@ -105,8 +105,8 @@ straight-forward.

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.