github.com/enetx/g@v1.0.80/examples/iter/iter_count.go (about) 1 package main 2 3 import ( 4 "github.com/enetx/g" 5 "github.com/enetx/g/f" 6 ) 7 8 func main() { 9 a := g.SliceOf(1, 2, 3) 10 println(a.Iter().Count()) // 3 11 12 a = g.SliceOf(1, 2, 3, 4, 5) 13 println(a.Iter().Count()) // 5 14 15 a = g.SliceOf(1, 2, 4, 3, 4, 5, 4, 1, 1, 4, 4) 16 17 println(a.Iter().Filter(f.Eq(4)).Count()) // 5 18 // println(a.Iter().Filter(func(i int) bool { return i == 4 }).Count()) // 5 19 }