Skip to content

Commit 0d1111f

Browse files
committed
readme: fix group.Of using
1 parent 05d5afb commit 0d1111f

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ import (
163163
"github.com/m4gshm/gollections/slice/group"
164164
)
165165

166-
var ageGroups = group.Of(users, func(u User) string {
166+
var ageGroups map[string][]User = group.Of(users, func(u User) string {
167167
return use.If(u.age <= 20, "<=20").If(u.age <= 30, "<=30").Else(">30")
168168
}, as.Is)
169169

@@ -519,10 +519,11 @@ var one = range_.Closed(1, 1).Slice() //[]int{1}
519519
import (
520520
"github.com/m4gshm/gollections/convert/as"
521521
"github.com/m4gshm/gollections/expr/use"
522+
"github.com/m4gshm/gollections/loop"
522523
"github.com/m4gshm/gollections/loop/group"
523524
)
524525

525-
var ageGroups = group.Of(users, func(u User) string {
526+
var ageGroups map[string][]User = group.Of(loop.Of(users...), func(u User) string {
526527
return use.If(u.age <= 20, "<=20").If(u.age <= 30, "<=30").Else(">30")
527528
}, as.Is)
528529

internal/docs/readme.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,10 @@ include::../examples/loopexamples/range_Closed_test.go[lines=12..16,indent=0]
310310
import (
311311
"github.com/m4gshm/gollections/convert/as"
312312
"github.com/m4gshm/gollections/expr/use"
313+
"github.com/m4gshm/gollections/loop"
313314
"github.com/m4gshm/gollections/loop/group"
314315
)
315-
include::../examples/loopexamples/group_Of_test.go[lines=16..22,indent=0]
316+
include::../examples/loopexamples/group_Of_test.go[lines=17..23,indent=0]
316317
----
317318
====== loop.ToMap, loop.ToMapResolv
318319
[source,go]

internal/examples/loopexamples/group_Of_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import (
77

88
"github.com/m4gshm/gollections/convert/as"
99
"github.com/m4gshm/gollections/expr/use"
10+
"github.com/m4gshm/gollections/loop"
11+
"github.com/m4gshm/gollections/loop/group"
1012
"github.com/m4gshm/gollections/slice"
11-
"github.com/m4gshm/gollections/slice/group"
1213
"github.com/m4gshm/gollections/slice/sort"
1314
)
1415

1516
func Test_Group(t *testing.T) {
1617

17-
var ageGroups = group.Of(users, func(u User) string {
18+
var ageGroups map[string][]User = group.Of(loop.Of(users...), func(u User) string {
1819
return use.If(u.age <= 20, "<=20").If(u.age <= 30, "<=30").Else(">30")
1920
}, as.Is)
2021

internal/examples/sliceexamples/group_Of_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
func Test_Slice_Group(t *testing.T) {
1616

17-
var ageGroups = group.Of(users, func(u User) string {
17+
var ageGroups map[string][]User = group.Of(users, func(u User) string {
1818
return use.If(u.age <= 20, "<=20").If(u.age <= 30, "<=30").Else(">30")
1919
}, as.Is)
2020

0 commit comments

Comments
 (0)