Blocks and Iterators (Part 1)

An iterator is a method of calling on a block of code which is somewhat similar to C, Java or Perl, somewhat. The usage of iterators in Ruby does something different as opposed to other languages that share similar functions. Initially a block normally appears adjacent a method or call, that call statement is written immediately after the method’s last parameter. Next, the chunk of code contained within the block is not done as it is executed rather it is remembered then has the code continue into the method. Then the block can be called as if it were a method in itself with the use of the “yield” statement.

This entry was posted in Development, Programming Basics and tagged , . Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.