Skip to content

Commit 4ef72f4

Browse files
committed
adding functions
1 parent 7963614 commit 4ef72f4

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ all the examples `Run` functions sequentially in line with the table of contents
2323
* [09 - Slices](slices/main.go)
2424
* [10 - Maps](maps/main.go)
2525
* [11 - Range](ranges/main.go)
26-
* [...]
26+
* [12 - Functions](functions/main.go)
2727
* [25 - Timers](timers/main.go)
2828
* [26 - Tickers](tickers/main.go)
2929
* [27 - WorkerGroups](workergroups/main.go)

functions/main.go

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package functions
2+
3+
import "fmt"
4+
5+
func Run() {
6+
noReturnFunction()
7+
functionWithArgs(1, 2, 3, 4, 5)
8+
functionSingleReturn()
9+
functionMultipleReturnValues()
10+
}
11+
12+
func noReturnFunction() {
13+
fmt.Println("I return nothing, implicitly")
14+
}
15+
16+
func functionWithArgs(args ...any) {
17+
fmt.Println(args...)
18+
}
19+
20+
func functionSingleReturn() int {
21+
return 10
22+
}
23+
24+
func functionMultipleReturnValues() (int, string, float64) {
25+
return 1, "two", 3.00
26+
}

0 commit comments

Comments
 (0)