4 ms·
Does not Interface{} work as well as Any? I mean, most languages have while-statements cause it is more clear what the intention is.
by AtNightWeCode 5y ago
Does 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.