Skip to content

Commit 76d66b8

Browse files
authored
Merge pull request #11 from golang-infrastructure/dev
examples: 增加API代码示例
2 parents 9b2a632 + b6ab9b7 commit 76d66b8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
File renamed without changes.

example/return_by_func/main.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
if_expression "github.com/golang-infrastructure/go-if-expression"
6+
)
7+
8+
func main() {
9+
10+
r := if_expression.ReturnByFunc(true, func() string {
11+
fmt.Println("True分支被执行了")
12+
return "是"
13+
}, func() string {
14+
fmt.Println("False分支被执行了")
15+
return "否"
16+
})
17+
fmt.Println(r)
18+
// Output:
19+
// True分支被执行了
20+
// 是
21+
22+
}

0 commit comments

Comments
 (0)