Message-ID: <261291454.3532.1369384641304.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3531_1895658278.1369384641304" ------=_Part_3531_1895658278.1369384641304 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Still having problems understanding generators, huh?
Don't worry - its easy stuff.
The basic syntax is:
In practice, it generally looks like this:
Let's start off easy:
After the generator expression is run, <local variable> will becom= e an enumerable object that you can iterate through, like an array, list, o= r collection. The contents of this enumerable object will be a collection o= f <expression>s.
<expression>s are variables that are put into <local variable&g= t; if <conditional expression> returns true. This means means that by= using a <conditional expression> in a generator, you can decide whic= h objects should be added to the enumerable <local variable>. <exp= ressions> can be manipulated further: for instance, this syntax is valid= :
In this instance, the return value of MethodToMutilateExpression will be= added to the enumerable <local variable>. This makes generators usef= ul to filter the input that MethodToMutilateExpression() will be called wit= h.
"for <declarations> in <iterator>" is your typical= for loop: "for item in collection," in otherwords.
Here's a simple working example of how generators work.
Here's the output:------=_Part_3531_1895658278.1369384641304--