3 ms·
But even the else keyword itself is reserved for special occasions in Go. The thing about the language is that if something seems awkward (which I agree your ex
by randomdata 10y ago
But even the else keyword itself is reserved for special occasions in Go. The thing about the language is that if something seems awkward (which I agree your example is), you have to ask if you are expressing it that way only because that is what you would do in other languages, or if there is a Go way to express it? More often than not, there is a better way to express it.
The code you gave serves no purpose, so it is difficult to see how it fits into the larger context of a real application, but it may be possible that you don't need an if/else statement like this at all.