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

Go does not support parameterized method #2

Open
snamiki1212 opened this issue Sep 15, 2024 · 0 comments
Open

Go does not support parameterized method #2

snamiki1212 opened this issue Sep 15, 2024 · 0 comments

Comments

@snamiki1212
Copy link
Owner

snamiki1212 commented Sep 15, 2024

Go has generics but cannot work when using method like this.

// ex)
// Syntax Error: method must have no type parameters syntax
func (us Users) Tap[T any](item T) T {
	return item
}

For that reason, go-gen-lo also cannot support some lo helpers.

// ex)
// Cannot implement because it is parameterized method
func (us Users) Reduce[R any](accumulator func(agg R, item User, index int) R, initial R) R {
	return lo.Reduce(us, accumulator)
}

REF

@snamiki1212 snamiki1212 pinned this issue Sep 15, 2024
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