CSC/ECE 517 Summer 2008/wiki1 2 itr

From Expertiza_Wiki
Revision as of 14:22, 30 May 2008 by Msvarghe (talk | contribs)
Jump to navigation Jump to search

Introduction

One of the beloved feature of Ruby is the block based Iterator. A Ruby Iterator is simply a method that somehow loops over the contents of an object without exposing its underlying representation. The verb `iterate' means "do the same thing many times' so `iterator' means "one which does the same thing many times'. It can also be considered as an object that behaves like a generic pointer. The iterator usually reference to one particular element in the object collection and then modify itself so that it points to the next element.

Problem Definition

Ruby, like Java, has iterators to facilitate doing operations on each member of a set. Python has generators as well. Describe how generators differ from iterators, and find examples of code sequences using generators that would be awkward with iterators.

Numbering

  1. A
    1. a
  2. B
    1. b

Bullets

  • A
    • a
  • B
    • b

Subsubsection

Webmail [1]