We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for (i <- 1 to 10) { s } += i
Why this code compile and work?
object TestForResults extends App { var s = 0 val a = for (i <- 1 to 10) { s } += i println(a) println(s) }
Output will be:
() 55
The text was updated successfully, but these errors were encountered:
Imported From: https://issues.scala-lang.org/browse/SI-5582?orig=1 Reporter: Tomas Shestakov (megaprog) Affected Versions: 2.9.1
Sorry, something went wrong.
@soc said: Hi Thomas,
this should have been asked on the mailing list first, probably.
Maybe it makes it a bit more clear, this code is equivalent:
for (i <- 1 to 10) s += i
The {} is not doing what you expect.
{}
@paulp said: I guess "why does this work" has some novelty value. Yes, please don't open bugs without some evidence there is a bug.
paulp
No branches or pull requests
Why this code compile and work?
Output will be:
() 55
The text was updated successfully, but these errors were encountered: