File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 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
7171 }).First () // take the first author
7272```
7373
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+
7499** More examples** can be found in [ documentation] ( https://godoc.org/github.com/ahmetalpbalkan/go-linq ) .
75100
76101## Release Notes
You can’t perform that action at this time.
0 commit comments