From d319310a7b7e4e99c8b09b6f34b718f91e13cdec Mon Sep 17 00:00:00 2001 From: thinhda Date: Wed, 1 Apr 2020 08:09:39 +0700 Subject: [PATCH] improve example --- README.md | 13 ++++++++++--- examples/example.go | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dabf15e..b3ed217 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,20 @@ for i := 0; i < 10; i++ { executor.Publish(func(input int) { fmt.Printf("2 ^ %d = %d \n", input, input^2) }, i) + + executor.Publish(func(a int, b int) { + fmt.Printf("%d + %d = %d \n", a, b, a+b) + }, i, i+1) } // Output: // 2 * 0 = 0 +// 2 ^ 0 = 2 // 2 ^ 1 = 3 -// 2 ^ 2 = 0 +// 1 + 2 = 3 // 2 * 2 = 4 -// 2 * 1 = 2 -// 2 ^ 0 = 2 +// 2 ^ 2 = 0 +// 2 + 3 = 5 +// 0 + 1 = 1 +// 2 * 1 = 2 ``` \ No newline at end of file diff --git a/examples/example.go b/examples/example.go index 1a8d150..47b5921 100644 --- a/examples/example.go +++ b/examples/example.go @@ -25,6 +25,10 @@ func main() { executor.Publish(func(input int) { fmt.Printf("2 ^ %d = %d \n", input, input^2) }, i) + + executor.Publish(func(a int, b int) { + fmt.Printf("%d + %d = %d \n", a, b, a+b) + }, i, i+1) } }