Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fdab687

Browse files
you're doing great
1 parent 0812982 commit fdab687

File tree

10 files changed

+140
-1
lines changed

10 files changed

+140
-1
lines changed

‎000_temp/63fall2018/003-func/func.go‎ renamed to ‎000_temp/63-fall-2018/003-func/func.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ func secondStatement() {
1818

1919
func finalStat() {
2020
fmt.Println("about to exit")
21-
}
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func main() {
8+
fname := "James"
9+
lname := "Bond"
10+
fmt.Println(fname, lname)
11+
girlfriend := "Miss Moneypenny"
12+
fmt.Println(girlfriend)
13+
}
14+
15+
/*
16+
declare, assign, initialize
17+
DECLARE a VARIABLE stores a VALUE of a certain TYPE
18+
we ASSIGN a VALUE of a certain TYPE to a VARIABLE
19+
declare & assign ==> initialize
20+
*/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
var x int
8+
var y string
9+
10+
func main() {
11+
fmt.Println(x)
12+
fmt.Println("|", y, "|")
13+
}
14+
15+
// zero value
16+
// if you declare a VAR of a certain TYPE
17+
// and do not ASSIGN a VALUE to that VAR
18+
// a ZERO VALUE will be ASSIGNED to that VAR
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
var x = 42
8+
var y = "M"
9+
10+
func main() {
11+
fmt.Println(x)
12+
fmt.Println(y)
13+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func main() {
8+
fmt.Println("Begin")
9+
10+
// pass in an ARGUMENT to the func when you CALL IT
11+
foo("James Bond")
12+
13+
x := "Miss Moneypenny"
14+
// pass in an ARGUMENT to the func when you CALL IT
15+
foo(x)
16+
17+
n, _ := fmt.Println("1")
18+
19+
fmt.Println("number of bytes written", n)
20+
}
21+
22+
// foo takes a VALUE of TYPE string
23+
// we could also say:
24+
// foo has a parameter which is a VALUE of TYPE string
25+
// funcs may be defined with PARAMETER(S)
26+
func foo(name string) {
27+
fmt.Println("Hello", name)
28+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// DECLARE a variable to be of a certain TYPE
8+
// we can only ever store VALUES of that TYPE in that VARIABLE
9+
// the VARIABLE has an IDENTIFIER
10+
// STATIC programming language
11+
// IDIOMATIC - idioms are patterns of speech
12+
// COMPILER will check to make sure our code is IDIOMATIC
13+
14+
var x int
15+
16+
func main() {
17+
x = 7
18+
fmt.Println(x)
19+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("This is the entry point beginning of the programming")
7+
8+
foo()
9+
10+
// call bar with ARGUMENTS
11+
a, b := bar("James Bond", 32)
12+
fmt.Println(a)
13+
fmt.Println("In 10 years Bond will be", b, "years old.")
14+
15+
fmt.Println(`Program "about" to exit`)
16+
}
17+
18+
func foo() {
19+
fmt.Println("Foo is here")
20+
}
21+
22+
// define bar with PARAMETERS
23+
// EXPRESSIONS evaluate to some VALUE, eg, y + 10
24+
// STATEMENT is a line of code to be executed
25+
func bar(x string, y int) (string, int) {
26+
return fmt.Sprint(x, " is here and he is ", y, " years old"), y + 10
27+
}
28+
29+
// we will pass ARGUMENTS in to a function that has been defined with PARAMETERS
30+
31+
// func receiver identifier(parameters) return(s) {code}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
x := 40
7+
y := 2
8+
z := x * y
9+
fmt.Println(z)
10+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /