A gentle introduction on the use of implicit values & conversions in Scala.
It also introduces some design patterns for which implicit(s) are the building blocks.
http://blog.stratio.com/developers-guide-scala-implicit-values-part/
12. The compiler’s toy box: Implicit conversions
Conversion:
Domain = R
-10.0, 1.3, 9.2, ….
Conversion, I am
your SOURCE
TYPE
And, I am your
TARGET TYPE
14. Facts
Actual implicit parameters are values.
Formal implicit parameters are all those in the implicit parameter list.
Only methods can have - a single - implicit parameter list.
Functions are values.
Guinea Pigs are pets, not food.
Implicit conversions are specially tagged functions, that is values.
Methods are not functions but can be assigned to function values thus
becoming functions so they can become implicit conversions.
17. The implicit contexterror: ambiguous implicit
values:
both value c of type => C
and value d of type => C
WHY?! WHAT?!
Where did that implicit
value came from???!!!
I DONT KNOW MORTY! BUT…
RUN! RUN! RUN!
18. The implicit context is, once tamed, is...
MOSTLY HARMLESS
Implicit Context (n)
The implicit context at a given point of your source code is
the set of implicit values available for the compiler to
perform type conversions or complete function calls when
that point of code is providing an unexpected type object or
missing some parameter in a function call.
That is… a mere backpack full of values for the compiler to use.