Implicit Conversion Implicit Conversions provide a nice way to extend libraries and functionality without changing the original code. Example: Add methods to String
Implicit Conversion Must Import the Object in order to use the new methods It looks like we are calling the repeat method on the string class!
Implicit Parameters Implicit parameters are used in a functions parameter list to denote that the parameter Is optional. Declare the parameter to be implicit Label the list as implicit so the compiler knows Which list to use.
Traits It is possible to have multiple traits that have the same method. This is known as stackable modifications By extending Arithmetic we are saying that this is only valid for classes that extend Arithmetic Calls the next compute method in line A hint to the compiler that you are “stacking” traits
Traits If you remember from the last example the result between the two runs were different. This is because we changed the order of the traits between the two executions. Ordering of traits makes a difference! By using something called linearization classes and all of the traits are put into a linear order (right to left). By putting them in this order, each time you call super the next method up the chain is invoked. 2 + 2 = 4 4 * 4 = 16 2 * 2 = 4 4 + 4 = 8