3 ms·
Subtleties are not necessary to be very useful. They, are just real subtleties. :) > > “for true {...} and for {...} are not eqivalent” > So what? The compil
by tapirl 1y ago
Subtleties 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...