Disable deprecation warnings in the Scala REPL

3.3k Views Asked by At

Is it possible to disable deprecation warnings in the Scala REPL?

E.g. when I type:

scala> List(1,2,3).toSet()

I get a deprecation warning:

<console>:12: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want.
        signature: GenSetLike.apply(elem: A): Boolean
  given arguments: <none>
 after adaptation: GenSetLike((): Unit)
       List(1,2,3).toSet()
                        ^

Is it somehow possible to disable those warnings?

PS: I know that this is not a good idea for development, just need it for a presentation.

1

There are 1 best solutions below

0
On BEST ANSWER

Warnings can be disabled by adding -nowarn flag. Example:

$ scala -nowarn

Then your example will print:

scala> List(1,2,3).toSet()
res0: Boolean = false

scala> 

However I don't recommend turning off those warnings (even for presentation). Please have a look at the result type of List(1,2,3).toSet(), it's Boolean not a Set[Int].