#from Design Patterns by Russ Olsen pg 128-129 module Shared class ArrayIterator def initialize(array) @array = array @index = 0 end def has_next? @index < @array.length end def item @array[@index] end def peek @array[@index] end def next_item value = @array[@index] @index += 1 value end end end