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
In this code (link: https://github.com/quii/learn-go-with-tests/blob/main/arrays-and-slices.md#write-enough-code-to-make-it-pass-4):
func SumAllTails(numbersToSum ...[]int) []int { var sums []int for _, numbers := range numbersToSum { if len(numbers) == 0 { sums = append(sums, 0) } else { tail := numbers[1:] sums = append(sums, Sum(tail)) } } return sums }
We can refactor it, so we can omit the else block by introducing the statement continue:
func SumAllTails(numbersToSum ...[]int) []int { var sums []int for _, numbers := range numbersToSum { if len(numbers) == 0 { sums = append(sums, 0) continue } tail := numbers[1:] sums = append(sums, Sum(tail)) } return sums }
The text was updated successfully, but these errors were encountered:
I disagree with that. I think the first approach has more clarity and reads pretty well
Sorry, something went wrong.
No branches or pull requests
In this code (link: https://github.com/quii/learn-go-with-tests/blob/main/arrays-and-slices.md#write-enough-code-to-make-it-pass-4):
We can refactor it, so we can omit the else block by introducing the statement continue:
The text was updated successfully, but these errors were encountered: