3 ms·
FWIW, Go linter suggestion is to to use i++ but i += 2. If you write i += 1, it'll suggest you should write i++ instead: main.go:6:2: should replace i += 1
by shurcooL 11y ago
FWIW, Go linter suggestion is to to use i++ but i += 2. If you write i += 1, it'll suggest you should write i++ instead:
main.go:6:2: should replace i += 1 with i++
That said, if it were removed, I'd probably be happy because it makes the language a little simpler, but I don't mind having it too much either, because it's a statement rather than an expression.
- asddubs 11y agowow, now that seems needlessly confusing. "use x += _" to increase x by any amount except one, in which case you use x++"
- PeCaN 11y ago+= 1 is a pretty common case though, it doesn't seem particularly arbitrary for it to be special. It's not "clean" or "minimal" but it is pretty convenient.