3 ms·
If you cut and paste probably the misaligned indentation is the least problem. Cut and paste should be avoided if it's not done during a refactoring (so actual
by mau 12y ago
If you cut and paste probably the misaligned indentation is the least problem. Cut and paste should be avoided if it's not done during a refactoring (so actual moving of code for better design).
Beginners usually think Python strong indentation is a weakness of the language. I actually find C++ freedom being more error prone:
if (a < b);
a = b
It's a not very frequent bug, but when it happens it takes you hours to spot. ;)
- maxiepoo 12y agoYes and in Go (and hopefully all curly-brace languages of the future) this is actually a syntax error, you need the braces: if (a < b) { a = b; }
- gnur 12y agoAnd you don't need the semicolons!
- TylerE 12y agoThe thing I don't get...if braces are mandatory (Good), why keep the now completely, unambiguously, irrelevant () around the cond?
- deleted 12y ago[deleted]
- CasualSuperman 12y agoThey're actually not required in Go.
- wtbob 12y agoYou don't need those parens in Go, and go fmt will in fact remove them/
- kyrra 12y agoIf you ran the code through gofmt, it would remove the () around the cond for you. I code go in SublimeText with GoSublime. On every save it runs the file through gofmt and reformats it for me. Keeps my code looking pretty with very little effort.
- dekhn 12y agoThis would never happen to me because I frequently format my doc, and it wouldn't be indented.