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

slice chunk的坑 #63

Closed
feeops opened this issue Nov 26, 2022 · 2 comments
Closed

slice chunk的坑 #63

feeops opened this issue Nov 26, 2022 · 2 comments

Comments

@feeops
Copy link

feeops commented Nov 26, 2022

package main

import (
	"fmt"

	"github.com/duke-git/lancet/v2/slice"
	"github.com/samber/lo"
)

func main() {
	arr := []string{"a", "b", "c"}
	fmt.Println(slice.Chunk(arr, 10))
	fmt.Println(lo.Chunk(arr, 10))
}

输出

[[a] [b] [c]]

[[a b c]]

当chunk长度大于slice长度时,lo库的处理逻辑是正确的

@duke-git
Copy link
Owner

package main

import (
	"fmt"

	"github.com/duke-git/lancet/v2/slice"
	"github.com/samber/lo"
)

func main() {
	arr := []string{"a", "b", "c"}
	fmt.Println(slice.Chunk(arr, 10))
	fmt.Println(lo.Chunk(arr, 10))
}

输出

[[a] [b] [c]]

[[a b c]]

当chunk长度大于slice长度时,lo库的处理逻辑是正确的

@feeops v2分支上已修复chunk, 下个版本会更新

@duke-git
Copy link
Owner

duke-git commented Dec 4, 2022

v2.1.11版本已修复。

@duke-git duke-git closed this as completed Dec 4, 2022
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

2 participants