Type Inference in Scala example

Let’s take a function definition and slim it down using type inference in our advantage:

def f: (Int => Int) = (x:Int) => x + 1
def f: (Int => Int) =  x      => x + 1
def f: (Int => Int) =            _ + 1
def f               = (x:Int) => x + 1
Advertisements