The problem of compiling a Scala sheet in IntelliJ

I have a worksheet containing

object test { val tableTest = new Array[String](1) tableTest.length } 

which returns

 tableTest: Array[String] = [Ljava.lang.String;@628c5fdf res0: Int = 1 

and it looks fine.

However, when I enter this worksheet:

 object test { val tableTest = new Array[String](1) tableTest(0) = "zero" } 

IntelliJ cannot compile and returns an error Unable to read an event from: rO0ABXNyADdvcmcuamV0YnJhaW5zLmpwcy5pbmNyZW1lbnRhbC...

Did I do something wrong?

+1
scala intellij-idea
source share
1 answer

I have the same problem with the latest idea and Scala plugin.
There seems to be a problem on the worksheet with the execution of any line that is computed for Unit. The destination is Unit, so your tableTest(0) = "zero" fails.

I temporarily solved it using the following workaround:

this line will fail with Error:Unable to read an event from:...

 println("Will fail") 

You can fix this by specifying this helper method and using it for any Unit expression:

 def unit(f: => Unit): String = {f; ""} unit(println("Will work")) 

You just need to ignore the line that it creates in the output panel with res0: String = You can also put this method into some object and import into any WS that you need.

Gaston.
@ktonga

+1
source share

All Articles