-
-
Notifications
You must be signed in to change notification settings - Fork 841
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
Implement Min/Max as variadic functions #224
Comments
Hi @dergus, For the current available functions, that'd be a breaking change. See an example here. While a variadic parameter may take a slice, you're still required to add We could still consider a second set of functions with the variadic parameters. @samber, if you think that makes sense, I would like to work on that as part of hacktoberfest. |
Hi, I see |
I implemented a version in more convenient way, I do not agree to change the interface, because the interface of the base library once opened to change will cause a lot of dissatisfaction. func MaxN[T constraints.Ordered](items ...T) T {
return Max(items)
}
func MinN[T constraints.Ordered](items ...T) T {
return Min(items)
} If you @samber looks good, please approve it. |
Having
Min
/Max
functions take a slice as an argument is a bit inconvenient when you have just two variables because then you have to create an array out of them just for calling Min/Max functions.And with variadic version you still could provide a slice if you wished by using the
...
operator.The text was updated successfully, but these errors were encountered: