Can I specialise a functions type parameters in Scala like I can with C++ template specialisation?

Viewed 970

I want to write a function that behaves differently depending on its type parameter. A simple example of what I want is shown below:

def f[Int] = "I'm an int"
def f[Float] = "I'm a float"
def f[Burger] = "You want fries with that?"

Is this possible in Scala or do I need some kind of work around?

3 Answers
Related