Tag Archives: Iterators

Integers and Iterators

There are a variety iterators that are useful with Ruby such as we’ve already seen in previous samples of code, such as n.times. Others are n.upto and n.downto for going up or down a series of integers and the step, which is more like the traditional loop statement. Their usage would be somewhat like: 3.times [...]

Posted in Development, Programming Basics | Also tagged | Comments closed

Blocks and Iterators (Part 2)

Anytime the “yield” statement is called upon it calls on the chunk of code within the block executing it returning control to where the yield statement was called continuing on its way till the process is finished. That’s where the magic of Ruby is, that a block can be made to function like a method [...]

Posted in Development, Programming Basics, Programming Language | Also tagged | Comments closed

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 [...]

Posted in Development, Programming Basics | Also tagged | Comments closed