Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(c *Collection[T]) Filter 无效的问题 #32

Open
attson opened this issue Sep 18, 2023 · 2 comments
Open

(c *Collection[T]) Filter 无效的问题 #32

attson opened this issue Sep 18, 2023 · 2 comments

Comments

@attson
Copy link

attson commented Sep 18, 2023

image

过滤应该和比较没有关系吧,直接使用入参函数就好了?

@attson
Copy link
Author

attson commented Sep 18, 2023

	items := []Item{
		{Id: 1},
		{Id: 2},
		{Id: 3},
		{Id: 4},
		{Id: 5},
	}

	newCollection := collection.NewCollection(items)

	filter := newCollection.Filter(func(item Item, key int) bool {
		return item.Id == 2
	})

	fmt.Println(filter)
	fmt.Println(newCollection)

&{[{1} {2} {3} {4} {5}] 0xc0000a8030 0x494aa0 }
&{[{1} {2} {3} {4} {5}] 0xc0000a8030 0x494aa0 }

@attson
Copy link
Author

attson commented Sep 18, 2023

#33 写了个pr可以看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant