Is it possible to create an unnamed implicit class or function in Scala?
For example, if I have the following implicit class:
implicit class ListIntExtras(list: List[Int]) {
def average = list.sum / list.size
}
I would prefer to be able to define it as something like implicit class _(list: List[Int])
because the name of the class ListIntExtras
is never actually used anywhere.
And the same goes for an implicit function:
implicit def intToDouble(i: Int): Double = i.toDouble
I would like to instead define that method as implicit def _(i: Int): ...
because, again, I am never referencing its actual name.
I know that this is possible for implicit val
s. For example, you can do implicit val _ = new Config()
which is useful because naming it anything other than _
seems like just a waste as it is never being referenced by name.