How do you define a type for a function in Scala?

后端 未结 2 971
滥情空心
滥情空心 2020-12-25 10:29

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 f

2条回答
  •  情深已故
    2020-12-25 11:02

    trait Foo {
      type MyFunction = (Int,Int) => Boolean
    
      def checkInts(f: MyFunction)
      def checkInts(f: Option[MyFunction])
    }
    

提交回复
热议问题