Enabling NamedTuples codebase-wide (without imports)

I would like to start using named tuples in my codebase, but I am tired of it requiring a special experimental import at the top of every file, like an infection. It discourages me (in a way that feels intentional) from using the feature alltogether because of how cumbersome it is to constantly write imports. My codebase is a private project, so I would like to enable whichever experimental features I want easily.

is there a flag I can set in build.sbt that will enable it codebase wide once and forall?

Thanks.

1 Like

Add these two to scalac options in the build tool of your choice: -experimental -language:experimental.namedTuples

Or if using scala / scala-cli use directive:

//> using options -experimental -language:experimental.namedTuples

Use scala -language:help to see list of all language feature options.
Repeated -language options are allowed

6 Likes