I'm hoping there is a way to define a type for a function in Scala.
For example, say I want a function that takes two Ints and returns a Boolean, I could define a function that uses that like this:
def checkInts(f: (Int,Int) => Boolean) = { // do stuff }
Is there a way to define the type of f? Then I could do something like:
def checkInts(f: MyFunctionType)
or
def checkInts(f: Option[MyFunctionType])
trait Foo { type MyFunction = (Int,Int) => Boolean def checkInts(f: MyFunction) def checkInts(f: Option[MyFunction]) }
2.1m questions
2.1m answers
60 comments
57.0k users