3 ms·
I've never used Go, but why not treat err like a Boolean? One of my favorite patterns in Python is a simple "if item: do x" where item can be a sequence, a stri
by 40acres 7y ago
I've never used Go, but why not treat err like a Boolean? One of my favorite patterns in Python is a simple "if item: do x" where item can be a sequence, a string, or even an integer, where certain values are considered False and certain values are considered True.
- frou_dh 7y agoIn general, they deliberately shunned implicit type conversions (in this case, error/interface → bool. Also notably between numerics). Probably due to being fed up from many years exposure to C's static-but-weakly-typed nature.