package t2237
object CodeInWorksheet {
println("Something, anything") //> Something, anything
case class A private[A] (i: Int)
val a1 = A(1) //> a1 : t2237.CodeInWorksheet.A = A(1)
}
While the following fails, with a blinking error:
package t2237
object CodeInWorksheet {
case class A private[A] (i: Int)
val a1 = A(1) // blinking error here
}
It is the result of bug in Scala (SI-8821) and a strange behavior of the worksheet.
The worksheet wraps the code inside the execute method only from the first expression. If the first (and the last) elements of the worksheet are class/object/trait definition, they stay outside of the execute.
Everything should be inside the execute method, otherwise it could some inconsistency, like class and its companion object not in the same context.
The following worksheet compiles and executes:
While the following fails, with a blinking error:
It is the result of bug in Scala (SI-8821) and a strange behavior of the worksheet.
The worksheet wraps the code inside the
execute
method only from the first expression. If the first (and the last) elements of the worksheet are class/object/trait definition, they stay outside of theexecute
.Everything should be inside the
execute
method, otherwise it could some inconsistency, like class and its companion object not in the same context.