-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatch_example_test.go
43 lines (32 loc) · 992 Bytes
/
match_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package stream_test
import (
"fmt"
"github.com/xuender/go-stream"
)
func ExampleBaseStream_AnyMatch() {
base1 := stream.NewBase(stream.Range2Channel(10))
base2 := stream.NewBase(stream.Copy(base1))
fmt.Println(base1.AnyMatch(func(num int) bool { return num > 100 }))
fmt.Println(base2.AnyMatch(func(num int) bool { return num > 1 }))
// Output:
// false
// true
}
func ExampleBaseStream_AllMatch() {
base1 := stream.NewBase(stream.Range2Channel(10))
base2 := stream.NewBase(stream.Copy(base1))
fmt.Println(base1.AllMatch(func(num int) bool { return num > 8 }))
fmt.Println(base2.AllMatch(func(num int) bool { return num >= 0 }))
// Output:
// false
// true
}
func ExampleBaseStream_NoneMatch() {
base1 := stream.NewBase(stream.Range2Channel(10))
base2 := stream.NewBase(stream.Copy(base1))
fmt.Println(base1.NoneMatch(func(num int) bool { return num > 100 }))
fmt.Println(base2.NoneMatch(func(num int) bool { return num > 1 }))
// Output:
// true
// false
}