3 ms·
Like it! Now, can they continue to add more “useless” improvements like while-loops and so on.
by AtNightWeCode 5y ago
Like it! Now, can they continue to add more “useless” improvements like while-loops and so on.
- jjice 5y agoDoesn't 'for' work as 'while' if you only give it a condition in go? I haven't written much, so correct me if I'm wrong.
- AtNightWeCode 5y agoDoes not Interface{} work as well as Any? I mean, most languages have while-statements cause it is more clear what the intention is.
- Zancarius 5y agoIt does, but with generics coming down the pipe, I feel that "any" expresses intent somewhat better in certain circumstances. Or at least it ought to improve readability-at-a-glance. I'd imagine you can continue using interface{} for the foreseeable future.
- Someone 5y agoSome languages even have real for statements because it makes more clear what the intention is. In Pascal, you can’t break out of a for statement, the limit and step value are evaluated only at start of the loop, and you can’t change the value of the variable being looped over. Consequently, the number of iterations through the loop taken is known when the loop gets entered.
- xh-dude 5y agoOTOH there’s no ‘while true’ or do-while or while-do, none of which are particularly fluent.
- ainar-g 5y agoIt does and it's enough for "while". What I do miss sometimes is the repeat-until / do-while loop. You can emulate it with "for" currently, but it's awkward.
- karmanyaahm 5y agohttps://go.dev/tour/flowcontrol/3 https://go.dev/tour/flowcontrol/3 for sum < 1000 { sum += sum }