There are two obvious ways to check for an empty string:
if s == "" { ... }
if len(s) == 0 { ... }
I like the first one since it seems slightly more obvious.
Is there a preferred form?
Thanks!
--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Programming in Python 3" - ISBN 0321680561
http://www.qtrac.eu/py3book.html
There are two obvious ways to check for an empty string:
if s == "" { ... }
if len(s) == 0 { ... }I like the first one since it seems slightly more obvious.
Is there a preferred form?
You already asked this same question one year ago:
http://groups.google.com/group/golang-nuts/browse_thread/thread/9d3478bec3c7c68d/998bb93f806bf052
I thought we had agreed s + "badgerbadgerbadger" ==
"badgerbadgerbadger" was the preferred way.
--
- yiyus || JGL .
Seems non-idiomatic. Shouldn't it be
s + "gophergophergopher" == "gophergophergopher"
?
Ultimately it's a matter of taste.
There's no effect on the generated code.
Russ