3 ms·
This isn't about Go. This is about a language construct (&& and ||) that I would argue is terrible and should never be used. Its mainly just sugar, and in my ex
by 38 2y ago
This isn't about Go. This is about a language construct (&& and ||) that I would argue is terrible and should never be used. Its mainly just sugar, and in my experience code heavy on these is harder to read and write. Couple that with truthiness and it's even worse.
- trealira 2y ago> This is about a language construct (&& and ||) that I would argue is terrible and should never be used. Something tells me you'd hate my five-line implementation of the standard library function fgets in C. char *fgets(char *buf, size_t n, FILE *fp) { char *p = buf; int c = 0; while (n > 1 && (c = getc(fp)) != EOF && (*p++ = c) != '\n') n--; return n > 0 && (c != EOF || feof(fp) && p != buf) ? *p = '\0', buf : 0; } I'm joking; I'd never write code this way in earnest.