@@ -2,7 +2,15 @@ package gorethink
22
33import p "github.com/dancannon/gorethink/ql2"
44
5- // Transform each element of the sequence by applying the given mapping function.
5+ // Map transform each element of the sequence by applying the given mapping
6+ // function. It takes two arguments, a sequence and a function of type
7+ // `func (r.Term) interface{}`.
8+ //
9+ // For example this query doubles each element in an array:
10+ //
11+ // r.Map([]int{1,3,6}, func (row r.Term) interface{} {
12+ // return row.Mul(2)
13+ // })
614func Map (args ... interface {}) Term {
715 if len (args ) > 0 {
816 args = append (args [:len (args )- 1 ], funcWrapArgs (args [len (args )- 1 :])... )
@@ -11,7 +19,14 @@ func Map(args ...interface{}) Term {
1119 return constructRootTerm ("Map" , p .Term_MAP , funcWrapArgs (args ), map [string ]interface {}{})
1220}
1321
14- // Transfor >m each element of the sequence by applying the given mapping function.
22+ // Map transforms each element of the sequence by applying the given mapping
23+ // function. It takes one argument of type `func (r.Term) interface{}`.
24+ //
25+ // For example this query doubles each element in an array:
26+ //
27+ // r.Expr([]int{1,3,6}).Map(func (row r.Term) interface{} {
28+ // return row.Mul(2)
29+ // })
1530func (t Term ) Map (args ... interface {}) Term {
1631 return constructMethodTerm (t , "Map" , p .Term_MAP , funcWrapArgs (args ), map [string ]interface {}{})
1732}
0 commit comments