I understand Ruby and Python\'s yield. What does Scala\'s yield do?
Yes, as Earwicker said, it's pretty much the equivalent to LINQ's select and has very little to do with Ruby's and Python's yield. Basically, where in C# you would write
from ... select ???
in Scala you have instead
for ... yield ???
It's also important to understand that for-comprehensions don't just work with sequences, but with any type which defines certain methods, just like LINQ:
map, it allows for-expressions consisting of a
single generator.flatMap as well as map, it allows for-expressions consisting
of several generators.foreach, it allows for-loops without yield (both with single and multiple generators).filter, it allows for-filter expressions starting with an if
in the for expression.