3 ms·
Rust has this innovative feature called "functions" which enables you to break from any block by just giving it a name and using "return". It can even return a
by svrb 6y ago
Rust has this innovative feature called "functions" which enables you to break from any block by just giving it a name and using "return". It can even return a value!
(/s obviously, but also not /s obviously. The serious point here may be that Java or whatever got in the way of defining functions by requiring them to be "methods" stuck in a "class" rather than, you know, just functions.)
- pirocks 6y agoA static function in Java is essentially just a function. Also I have no idea what functions being associated with classes has to do with breaking out of loops.
- gpderetta 6y agoencapsulate your nested loops in a function and return to exit multiple loops at the same time. Having nested lightweight functions allows minimal syntactical overhead compared to plain loops, although still not zero.