|
|
|
|
|
by bugfix-66
1338 days ago
|
|
Go is very close to C. A C programmer who understands a for loop should be able to fix this, despite the fact it's Go: // We are generating n-1, n-2, ..., 1, 0
func below(n uint64, to chan uint64) {
for n--; n >= 0; n-- {
to <- n
}
close(to)
}
Maybe you're right: It could be that C programmers don't understand Go syntax and Go programmers tend to be less experienced. |
|
It told me I have an error ("what happens at zero") when i do:
but running that function with several test inputs produces what I expected. Note, I removed the channel (replaced with println) as that doesn't add anything to the problem.Note: I've been programming (including C and C++) for 3+ decades. I make mistakes all the time, but.... what exactly are you looking for here if my solution is not ruight?
EDIT: the pasted code is also incorrect, because I didn't complete converting the for loop into a while.