While it is recommended to turn on compiler flags like -Wvalue-discard
or -Wunused:implicits
either explicitly or implicitly throught the use of sbt-tpolecat.
Sometimes you need to workarround those, but in a way that makes it explicit; since we generally consider such things bugs and that was the reason for using the compiler flags in the first place.
One, somewhat common, workarroud for those cases is the following void
function (courtesy of Rob Norris).
@inline final def void(args: Any*): Unit = (args, ())._2
However, such function has two problems.
- It has a couple of unnecesary extra allocations; namely the Seq for the varargs and the Tuple.
- It is not part of the stdlib and adding it on all projects is somewhat tedious.
Is there any other good workarroud that works out of the box?