As for looping mechanisms, Ruby has a rich set. The while and until control structures are both pretest loops, and both work as expected: One specifies a continuation condition for the loop, and the other specifies a termination condition. They also occur in "modifier" form such as if and unless. There is also the loop method of the Kernel module (by default an infinite loop), and there are iterators associated with various classes.
# Loop 1 (while) | # Loop 2 (until) |
# Loop 3 (for) | # Loop 4 ('each' iterator) |
# Loop 5 ('loop' method) | # Loop 6 ('loop' method) |
# Loop 7 ('times' iterator) | # Loop 8 ('upto' iterator) |
# Loop 9 (for) | # Loop 10 ('each_index') |
No comments:
Post a Comment