▲ | nirui 3 days ago | |
The chosen example:
Sounded more like a nitpicking.If you really care about scope while being able to use `bar` later down, the code should be written as:
which actually overwrites `err`, opposite to "shadowing" it.The confusing here, is that the difference between `if err != nil` and `if err = call(); err != nil` is not just style, the later one also introduces a scope that captures whatever variables got created before `;`. If you really REALLY want to use the same `if` style, try:
|