Implicit Classes, Scala.
method: implicit class IntFactorial(val n: Int) { def factorial: Int = { def fact(x: Int, acc: Int): Int = if (x <= 1) acc else fact(x - 1, acc * x) fact(n, 1) } } In this case, the implicit class does not extend AnyVal, because it needs to perform a recursive calculation, which is not possible