-
-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Reverse mutating? #160
Comments
@xyluet I guess they know it because almost all methods here mutating the inputs
|
@xyluet I've found out this lib github.com/thoas/go-funk, not sure if it is much better, but at least "reverse" func isn't mutate an input array) |
Good catch @xyluet ! I doubt that's expected. I had a quick look and it looks like only |
I had the same problem. And I think it will be more apparent if the |
Many libraries have used the following method to convert String to []byte. If the method modifies the original data, panic will occur. func StringToBytes(s string) []byte {
return unsafe.Slice(unsafe.StringData(s), len(s))
} Just like this kind of code, panic will appear: |
Available as an option |
I made a copy of lo.Reverse and lo.Shuffle into mutable/ sub-package. Legacy functions are deprecated. |
method
Reverse
is mutating the original collection, is this expected?output:
The text was updated successfully, but these errors were encountered: