Some function arguments can be declared implicit
.
Then, at compile-time, the only value matching the type of that argument is used. If there is no matching argument or there is more than one, then a compile-time error results.
Implicits appear like a potential problem at superficial glance, since what about side-effects?
But actually, we can encode an extremely powerful concept called type-classes[15] with implicit
arguments.
We can also do what the dynamic typing guys are doing, but with the advantage of safety[16]
scala> implicit def i(s: String) = new { def parseInt = Integer.parseInt(s) } i: (String)java.lang.Object{def parseInt: Int} scala> val v = "456".parseInt v: Int = 456