4 ms·
A good use for it is to exit early from deeply nested loops, which normally would require several "break"s. Some languages (Java, for instance) support "named b
by OskarS 10y ago
A good use for it is to exit early from deeply nested loops, which normally would require several "break"s. Some languages (Java, for instance) support "named breaks", but they tend to be more confusing than just using a goto.
This is more or less the only time I would use a goto over similar constructions like switch/case or continue/break.