What is the output for this program?
Source: https://twitter.com/davecheney/status/1215006731610124288
package main
import (
"fmt"
)
func isEven(v int) bool {
if (v % 2) == 1 {
goto false
}
return !false
false:
return false
}
func main() {
fmt.Println(isEven(2020))
}
Top comments (9)
Thanks, got to know that "true" and "false" can be a variable name or label. Here is another version.
That's cool
Hi Manigandand
First of all welcome to dev.to and congrats for this first post.
I noticed the program of your post comes from a tweet from Dave Cheney:
I think it would be better if you cited this source.
I don't think dev.to has any rules against this kind of content reuse, and I'm not personnaly against it, however I find it more honest to always cite sources.
agree
true
yup! Good
true. because 2020 % 2 == 0
true
Where is the tips1 there?
Some comments have been hidden by the post's author - find out more