Angenommen, ich habe zwei Funktionen f
und g
:andthen für die Funktion von zwei Argumenten in Scala
val f: (Int, Int) => Int = _ + _
val g: Int => String = _ + ""
Nun würde Ich mag sie eine Funktion h
val h: (Int, Int) => String = f andThen g
Leider ist es zu bekommen mit andThen
komponieren kompiliert nicht :(
scala> val h = (f andThen g)
<console> error: value andThen is not a member of (Int, Int) => Int
val h = (f andThen g)
Warum kompiliert es nicht und wie kann ich f
und g
zusammensetzen, um (Int, Int) => String
zu bekommen?
Mögliche Duplikate von [Warum hat Function2 keine andThen-Methode?] (Https://stackoverflow.com/questions/21680117/why-doesnt-function2-have-an-andthen-method) – theon