How to use the Scala 3 nightly build as your REPL

As a brief note, if you want to use the Scala 3 nightly build as your REPL, one way to do that is with this project I just put on Github. Just:

  1. Clone that project
  2. cd into its directory
  3. Type sbt to start sbt
  4. Type console to start a Scala 3 REPL inside sbt
  5. Use the latest, greatest Scala syntax, as shown in this image:

How to use Scala 3 nightly build REPL with sbt

The hack that makes this work is in the build.sbt file, and shown here in bold:

lazy val root = project
  .in(file("."))
  .settings(
    name := "Scala3Nightly",
    description := "Lets me use the Scala 3 nightly build",
    version := "0.1.0",
    scalaVersion := dottyLatestNightlyBuild.get,
    useScala3doc := true,
  )

As shown in the build.sbt file, I found that scalaVersion hack on this page: github.com/scala/scala3-example-project.

Sorry, I have to run off to a meeting now, but if you want to use the latest Scala 3 nightly build as your REPL, I hope this is helpful.

(Also, as shown in this gitter.im/dotty link, you can use Coursier for this purpose, but in this case it’s much easier to use this sbt hack to create a Scala 3 REPL with the latest nightly build, imho.)

... this post is sponsored by my books ...