Ruby, C, Java and more - getting out of loops
Archive - Originally posted on "The Horse's Mouth" - 2008-03-19 16:07:01 - Graham Ellisbreak and continue statements have been available for loop control for many years, and others functionallity has been added such as Perl's redo. From today's Ruby Course, here's a table that compares these loop controls in Ruby to similar commands in the other languages that I have been discussing with this week's course.
C/Java | Perl | Ruby | effect |
---|---|---|---|
break | last | last | Get me out the loop NOW! |
continue | next | next | go for the next loop iteration |
- | redo | redo | rerun current loop iteration |
- | - | retry | let's start the loop again, should we? |