Commit b1c935a 1 parent 28f0008 commit b1c935a Copy full SHA for b1c935a
File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,31 @@ author := From(books).SelectMany( // make a flat array of authors
71
71
}).First () // take the first author
72
72
```
73
73
74
+ ** Example: Implement a custom method that leaves only values greater than the specified threshold**
75
+ ``` go
76
+ type MyQuery Query
77
+
78
+ func (q MyQuery ) GreaterThan (threshold int ) Query {
79
+ return Query{
80
+ Iterate: func () Iterator {
81
+ next := q.Iterate ()
82
+
83
+ return func () (item interface {}, ok bool ) {
84
+ for item, ok = next (); ok; item, ok = next () {
85
+ if item.(int ) > threshold {
86
+ return
87
+ }
88
+ }
89
+
90
+ return
91
+ }
92
+ },
93
+ }
94
+ }
95
+
96
+ result := MyQuery (Range (1 ,10 )).GreaterThan (5 ).Results ()
97
+ ```
98
+
74
99
** More examples** can be found in [ documentation] ( https://godoc.org/github.com/ahmetalpbalkan/go-linq ) .
75
100
76
101
## Release Notes
You can’t perform that action at this time.
0 commit comments