Skip to content

Commit

Permalink
Add presentation demo (for and func)
Browse files Browse the repository at this point in the history
  • Loading branch information
benson1029 committed Apr 16, 2024
1 parent 9d60129 commit 334f02c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions public/examples/demo-for.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import "fmt"

func main() {
var f func() int32;
for i := 1; i <= 10; i++ {
f = func() int32 { return i; }
i++
fmt.Println(i)
} // output: 2, 4, 6, 8, 10
fmt.Println(f()) // output: 10
}
12 changes: 12 additions & 0 deletions public/examples/demo-func.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

var y = 0;

func f(x int32) int32 {
z := 2;
return x + y;
}

func main() {
f(1);
}

0 comments on commit 334f02c

Please sign in to comment.