File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -57,3 +57,24 @@ func main() {
57
57
fmt.Println (" sum: " , d) // sum: 5
58
58
}
59
59
```
60
+
61
+ ## Multiple arguments and returns
62
+ ``` go
63
+ func main () {
64
+
65
+ t := promise.
66
+ New (func (resolve promise.Accept , reject promise.Decline ) {
67
+ resolve (1 )
68
+ }).
69
+ Then (func (n int ) (int , int , float64 , promise.Promise ) {
70
+ return n, 2 , 3.5 , promise.Resolve (4.5 )
71
+ }).
72
+ Then (func (a, b int , c, d float64 ) int {
73
+ return int (float64 (a) + float64 (b) + c + d)
74
+ })
75
+
76
+ d := t.Result ()
77
+
78
+ fmt.Println (" total: " , d)
79
+ }
80
+ ```
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/samuelngs/go-promise"
7
+ )
8
+
9
+ func main () {
10
+
11
+ t := promise .
12
+ New (func (resolve promise.Accept , reject promise.Decline ) {
13
+ resolve (1 )
14
+ }).
15
+ Then (func (n int ) (int , int , float64 , promise.Promise ) {
16
+ return n , 2 , 3.5 , promise .Resolve (4.5 )
17
+ }).
18
+ Then (func (a , b int , c , d float64 ) int {
19
+ return int (float64 (a ) + float64 (b ) + c + d )
20
+ })
21
+
22
+ d := t .Result ()
23
+
24
+ fmt .Println ("total: " , d )
25
+ }
You can’t perform that action at this time.
0 commit comments