4 ms·
Why don't they at least allow "if err" rather than "if err != nil", i.e. allow error values to be truth-tested? I don't think I've seen that suggested anywhere
by iainmerrick 7y ago
Why don't they at least allow "if err" rather than "if err != nil", i.e. allow error values to be truth-tested?
I don't think I've seen that suggested anywhere, which is surprising to me. I guess it's fear of scope creep, of allowing syntactic shortcuts that might be ambiguous or dangerous in other circumstances? But I would have thought it could be restricted to error types.
- networkimprov 7y agoThis proposal https://github.com/golang/go/issues/32611 https://github.com/golang/go/issues/32611 suggests: on err, <single_statement>
- iainmerrick 7y agoThat’s not the same.