Implicit Classes, Scala.
with value types. We can use this implicit class like this: scala> 5.factorial res2: Int = 120 So, in this example, we see that extending AnyVal is not always the right choice, as the more complex logic required by the factorial method makes it more appropriate to use a normal class that does not