You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Scala for Python Developers page does have a section comparing Scala's comprehensions to Python's list comprehensions, but (AFAICT) lacks any information about what Scala's analogue is to Python's generator expressions, which are like list comprehensions but lazily evaluated.
From the answers to a StackOverflow question about this, I got that in Scala, lazy evaluation or not is decided by the object being iterated over, because comprehensions just desugar to object.map() calls and the like, which of course get to determine the output type in full (unlike Python, where iterated-over objects only get to determine the element type).
It would be nice if one equivalent to a generator expression using a .view or something like that was briefly demonstrated, maybe with a short comment explaining this (although it seems like the existing examples are kept comment-free on purpose, so maybe not if the goal is to really keep it short - but in that case, maybe there could be a longer explanation further down the page).
The text was updated successfully, but these errors were encountered:
The Scala for Python Developers page does have a section comparing Scala's comprehensions to Python's list comprehensions, but (AFAICT) lacks any information about what Scala's analogue is to Python's generator expressions, which are like list comprehensions but lazily evaluated.
From the answers to a StackOverflow question about this, I got that in Scala, lazy evaluation or not is decided by the object being iterated over, because comprehensions just desugar to
object.map()
calls and the like, which of course get to determine the output type in full (unlike Python, where iterated-over objects only get to determine the element type).It would be nice if one equivalent to a generator expression using a
.view
or something like that was briefly demonstrated, maybe with a short comment explaining this (although it seems like the existing examples are kept comment-free on purpose, so maybe not if the goal is to really keep it short - but in that case, maybe there could be a longer explanation further down the page).The text was updated successfully, but these errors were encountered: