From c6164f252f8beb7062b185121644c95442eea907 Mon Sep 17 00:00:00 2001
From: "grejo.j"
Date: Mon, 19 Dec 2022 10:42:47 +0530
Subject: [PATCH] moved info from .sh to .go
---
examples/variables/variables.go | 1 +
examples/variables/variables.hash | 4 ++--
examples/variables/variables.sh | 8 +-------
public/variables | 24 +++++-------------------
4 files changed, 9 insertions(+), 28 deletions(-)
diff --git a/examples/variables/variables.go b/examples/variables/variables.go
index 8e0912f..5fa61d4 100644
--- a/examples/variables/variables.go
+++ b/examples/variables/variables.go
@@ -29,6 +29,7 @@ func main() {
// The `:=` syntax is shorthand for declaring and
// initializing a variable, e.g. for
// `var f string = "apple"` in this case.
+ // This syntax is only available inside functions.
f := "apple"
fmt.Println(f)
}
diff --git a/examples/variables/variables.hash b/examples/variables/variables.hash
index 040888b..2665b92 100644
--- a/examples/variables/variables.hash
+++ b/examples/variables/variables.hash
@@ -1,2 +1,2 @@
-736ce4018f275bb8d12e5232349bae93611506b2
-iYyAIilyBRf
+9aeef52b289d7ad9b9ac79f129d4e49f956c60ef
+N5rWndIliJW
diff --git a/examples/variables/variables.sh b/examples/variables/variables.sh
index eb3b20d..9c3e69e 100644
--- a/examples/variables/variables.sh
+++ b/examples/variables/variables.sh
@@ -3,10 +3,4 @@ initial
1 2
true
0
-apple
-
-# The shorthand `:=` initialization of variable can
-# only be used inside any function.
-# If used outside any function, it would generate
-# `syntax error: non-declaration statement outside
-# function body`.
+apple
\ No newline at end of file
diff --git a/public/variables b/public/variables
index 7bf1c69..11c6fee 100644
--- a/public/variables
+++ b/public/variables
@@ -43,7 +43,7 @@ calls.
- 
+ 
package main
|
@@ -133,7 +133,8 @@ zero value for an int
is 0
.
The := syntax is shorthand for declaring and
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.
|
@@ -154,7 +155,7 @@ initializing a variable, e.g. for
|
|
-
+ |
$ go run variables.go
initial
@@ -165,21 +166,6 @@ initializing a variable, e.g. for
|
-
-
- The shorthand := initialization of variable can
-only be used inside any function.
-If used outside any function, it would generate
-syntax error: non-declaration statement outside
-function body .
-
- |
-
-
-
- |
-
-
@@ -195,7 +181,7 @@ function body.