Why doesn't Function2 have an andThen method?

后端 未结 4 687
南笙
南笙 2021-02-13 04:12

Why does andThen only exist for single argument functions in Scala?

The following code works:

val double = (x: Int) => x * 2
val timesFou         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 05:00

    I have just noticed it is easy to work around with the following:

    val multiplyAndDouble = multiply.tupled andThen double
    val res = multiplyAndDouble(1, 3) // res = 6
    

提交回复
热议问题