Is it possible to do match-case
over functions?
I want to define a behavior for different types of functions. Say I have the following possibilities:
f: T => Int
f: T => String
f: T => Lis[Int]
f: T => Boolean
f: T => Double
- ...
and for each of these options I have a function; for example for Int
output:
def doThisForInt(f: T => Int) = { ... }
and this for Boolean
output:
`
def doThisForBoolean(f: T => Boolean) = { ... }
So now suppose a function definition is given: val f = (input: T) => true
. We should choose the corresponding case to f: T => Boolean
.
Note that all these functions differ in the output type. Alternatively, given f
can I get the output type of this function?