I understand Ruby and Python\'s yield. What does Scala\'s yield do?
Consider the following for-comprehension
val A = for (i <- Int.MinValue to Int.MaxValue; if i > 3) yield i
It may be helpful to read it out loud as follows
"For each integer i, if it is greater than 3, then yield (produce) i and add it to the list A."
In terms of mathematical set-builder notation, the above for-comprehension is analogous to
which may be read as
"For each integer , if it is greater than
, then it is a member of the set
."
or alternatively as
" is the set of all integers
, such that each
is greater than
."