Message-ID: <125461147.1305.1369218281053.JavaMail.firstname.lastname@example.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1304_1511564051.1369218281052" ------=_Part_1304_1511564051.1369218281052 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Generator methods are defined by the use of the yield keyword:
Given the definition above the following program would print the first f= ive elements of the Fibonacci series:
So although the generator definition itself is unbounded (a while true l= oop) only the necessary elements will be computed, five in this particular = case as the zip builtin will stop asking for more when the range is exauste= d.
Generator methods are also a great way of encapsulating iteration logic:=------=_Part_1304_1511564051.1369218281052--