Scala
What is a ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
What is a generator in the following code?
for(i <- 1 to 10) println(i)
i <- 1 to 10
1 to 10
for(i <- 1 to 10)
println(i)
Explanation
A generator defines a named val and assigns to it a series of values in a for expression. For example, in for(i <- 1 to 10), the generator is “i <- 1 to 10”. The value to the right of the <- is the generator expression.
Source:
generator
for expressions
generator
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
What will be the result of the following code execution? ...
What is a generator expression in the following code? ...
Is it possible to use variable trimmed in the code below without declarin...
S
cala
Quiz
Login to learn Scala
or
Read more about
Scala Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
Scala quizzes
Which character do you use instead of " * " for importing all the names of a pac...
How would you change declaration of function foo to ensure that a functi...
What is the largest Tuple that Scala supports?...
Can methods, taking one argument, be used with infix syntax?...
What is a higher-order function?...
Scala's Unit roughly corresponds to which Java type?...
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment