How do I make lambda functions generic in Scala?
Posted
by
Electric Coffee
on Stack Overflow
See other posts from Stack Overflow
or by Electric Coffee
Published on 2013-06-28T20:14:14Z
Indexed on
2013/06/28
22:21 UTC
Read the original article
Hit count: 199
As most of you probably know you can define functions in 2 ways in scala, there's the 'def' method and the lambda method...
making the 'def' kind generic is fairly straight forward
def someFunc[T](a: T) { // insert body here
what I'm having trouble with here is how to make the following generic:
val someFunc = (a: Int) => // insert body here
of course right now a is an integer, but what would I need to do to make it generic?
val someFunc[T] = (a: T) =>
doesn't work, neither does val someFunc = [T](a: T) =>
Is it even possible to make them generic, or should I just stick to the 'def' variant?
© Stack Overflow or respective owner