Sunday, September 20, 2009

those redundant brackets :)

this or similar fragment of code :
val a="Hello"
println a
for (i<-args data-blogger-escaped-blockquote="" data-blogger-escaped-i="" data-blogger-escaped-println="">will produce the following error from Scala 2.7.5 compiler:
error: illegal start of simple expression
for (
- which is an example of wrongly reported problem.
The real issue here not with for (which is fine) but with the fact that println argument is not in brackets, and there is no semicolon ending the string. Therefore, the compiler apparently tries to look ahead finding if there is more to add to this string, finds something it doesn't get, and reports an error.

Putting the brackets around the arguments in first println:
val a="Hello"
println (a)
for (i<-args data-blogger-escaped-blockquote="" data-blogger-escaped-i="" data-blogger-escaped-println="">solves it :)

No comments:

Post a Comment