break 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? |
(written 2008-03-19 16:07:01)
Associated topics are indexed under
C203 - C and C based languages - Conditionals and Loops [2570] Function Prototypes in C - (2010-01-11)
[2002] New C Examples - pointers, realloc, structs and more - (2009-01-20)
[1696] Saying NOT in Perl, PHP, Python, Lua ... - (2008-07-04)
[1220] for loop - how it works (Perl, PHP, Java, C, etc) - (2007-06-06)
[1191] Smart English Output - via PHP and Perl ? : operator - (2007-05-18)
[962] Breaking a loop - Ruby and other languages - (2006-12-03)
[353] Wimbledon Neck - (2005-06-20)
G908 - Well House Consultants - Language Comparisons [1990] Speaking all the languages - (2009-01-12)
[1717] Q - Should I use Perl or Python? - (2008-07-23)
[209] FAQ - Perl or PHP - (2005-02-11)
J704 - Java - Loops and Conditional StatementsP206 - Perl - More Loops and Conditionals [1825] Question Mark - Colon operator (Perl and PHP) - (2008-10-08)
[657] The ternary operator in Python - (2006-03-25)
[299] What - no switch or case statement? - (2005-05-03)
[138] Perl - redo and last without a loop - (2004-12-02)
R104 - Ruby - Control Structures [2619] Passing code to procedures and yield in Ruby - (2010-02-02)
[2471] A short form of if ... then ... else - (2009-10-23)
[2287] Learning to program in Ruby - examples of the programming basics - (2009-07-15)
[1904] Ruby, Perl, Linux, MySQL - some training notes - (2008-11-23)
[1891] Ruby to access web services - (2008-11-16)
[1887] Ruby Programming Course - Saturday and Sunday - (2008-11-16)
[1870] What to do with a huge crop of apples - (2008-11-04)
[1738] Clean code, jump free (Example in Lua) - (2008-08-06)
[1587] Some Ruby programming examples from our course - (2008-03-21)
[1163] A better alternative to cutting and pasting code - (2007-04-26)
[995] Ruby's case - no break - (2006-12-17)
[985] Equality in Ruby - == eql? and equal? - (2006-12-14)
[960] 1st, 2nd, 3rd revisited in Ruby - (2006-12-02)
Some other Articles
Variable types in RubyWell House Consultants / Manor - StaffUsing Structs and Unions together effectively in CBusinesses in West Wiltshire - networkingRuby, C, Java and more - getting out of loopsWhat is an lvalue? (Perl, C)Congratulations, Martin and MartaRome, and the faith of RomePlease don't shout at me!Spring and early summer training courses