We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When we convert an array of strings to numbers, the Map function is called.
Map
numbers := Map(strs, func(item string, index int) int { number, err := strconv.Atoi(item) if err != nil { // log return 0 } return number })
Errors during conversion must be ignored and the loop cannot be terminated early. I want to increase the definition of the function with error:
func Map[T any, R any](collection []T, iteratee func(item T, index int) (R, error)) ([]R, error) { result := make([]R, len(collection)) var err error for i, item := range collection { result[i],err = iteratee(item, i) if err != nil { // log return nil, err } } return result, nil }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When we convert an array of strings to numbers, the
Map
function is called.Errors during conversion must be ignored and the loop cannot be terminated early. I want to increase the definition of the function with error:
The text was updated successfully, but these errors were encountered: