Asking scala its version

After reading several posts on this forum and also on stackexchange, I’m really wondering why there’s no scala runtime facility for asking the scala version.

Does anyone know the reason for this limitation? Is it just deemed unnecessary, or is there some actual limitation which makes it impossible? Is there a way which I just haven’t found?

For example, int he IntelliJ worksheet which imitates a REPL, I’d like to ask which scala version I’m using.

scala.util.Properties provides various query methods for the Scala version.

Thanks, that’s interesting. My value of scala.util.Properties.releaseVersion prints as Some(2.12.7) from within the intelliJ scala worksheet.

However, when I use the goto source feature of intellij it takes me to the Properties.scala file in org.scala-lang:scala-library:2.13.3:jar

In fact the build.sbt file for my project indicates scalaVersion := "2.13.3".

You could try to configure the worksheet to execute in “Plain” rather than “REPL” mode, whatever that means - Scala scratch files and worksheets in IntelliJ don’t seem terribly well documented. “REPL” seems to be the default. In “Plain” mode it picks up the sbt Scala version, in “REPL” mode it consistently uses 2.12.7 (probably the version sbt itself is running on).

Sounds like yet another reason to rely on worksheets/scratch files only sparingly, if at all…