Reputation: 501
I am very new to scala and Intellij.
I installed intellij community edition 2020.1 on
Ubuntu 18.04.4 LTS using snap.
I have sbt 1.3.13, Scala 2.13.3, and JDK 1.8.
Somwhow scala worksheet is not producing any output on the right pane.
I spent time doing google etc. made sure I opened a scala sbt project.
Attaching screenshot.
Any idea, or pointer to try.
Thanks for your patience.
Upvotes: 0
Views: 184
Reputation: 48410
Singleton object are created lazily
An object is a class that has exactly one instance. It is created lazily when it is referenced, like a lazy val.
so you have to actually call the object after creating it like so
object simple_test {
val s = 4
println(s)
}
simple_test
This should now output something like
4 res0: simple_test.type = simple_test$@3e32d495
This is similar to what happens in the following snippet
lazy val x = {
val s = 4
println(s)
}
x
Upvotes: 2