3 ms·
The examples in your link don’t seem to be very useful compared to the subject of this post. “for true {...} and for {...} are not eqivalent” So what? The com
by NuclearPM 1y ago
The examples in your link don’t seem to be very useful compared to the subject of this post.
“for true {...} and for {...} are not eqivalent”
So what? The compiler will tell you the first time you try to run that “for true” abomination that it is invalid code.
- tapirl 1y agoSubtleties are not necessary to be very useful. They, are just real subtleties. :) > > “for true {...} and for {...} are not eqivalent” > So what? The compiler will tell you the first time you try to run that “for true” abomination that it is invalid code. It teaches you know that, when you write func bar() int { for true { ... } return 0 // whatever } You can write it as func bar() int { for { ... } } The compiler will not teach you this. ;D Usefulness might be subjective. Personally, the last two subtleties mentioned in the article are useful for me too. You may find some useful (in your opinion) subtleties in the Go Details and Tips 101 book: https://go101.org/details-and-tips/101.html https://go101.org/details-and-tips/101.html, and some since-Go-1.22/3 ones here: https://go101.org/blog/2024-03-01-for-loop-semantic-changes-in-go-1.22.html https://go101.org/blog/2024-03-01-for-loop-semantic-changes-... and https://go101.org/blog/2025-03-15-some-facts-about-iterators.html https://go101.org/blog/2025-03-15-some-facts-about-iterators...