Supponiamo che io ho due funzioni f
e g
:andthen per la funzione di due argomenti a Scala
val f: (Int, Int) => Int = _ + _
val g: Int => String = _ + ""
Ora vorrei comporli con andThen
per ottenere una funzione h
val h: (Int, Int) => String = f andThen g
Purtroppo non compila :(
scala> val h = (f andThen g)
<console> error: value andThen is not a member of (Int, Int) => Int
val h = (f andThen g)
Perché non compila e come posso comporre f
e g
per ottenere (Int, Int) => String
?
Eventuali duplicati di [Perché non Function2 dispone di un metodo di andthen?] (Https://stackoverflow.com/questions/21680117/why-doesnt-function2-have-an-andthen-method) – theon