Tuesday, February 24, 2015

#~ class Array
  #~ def reverse_iterate
    #~ current_index = self.size-1
    #~ while current_index >= 0
      #~ yield self[current_index]
      #~ current_index -= 1
    #~ end
  #~ end
#~ end
#~ 
#~ [2,4,6,8].reverse_iterate { |i| print "#{i} "}

class Array
  def each_anil &block
    yield self
  end
end


[2,4,6,8].each_anil {|p| puts p}

No comments:

Post a Comment