मान लीजिए मैं दो कार्यों f
और g
है:andthen स्काला में दो तर्क के समारोह के लिए
val f: (Int, Int) => Int = _ + _
val g: Int => String = _ + ""
अब मैं h
val h: (Int, Int) => String = f andThen g
दुर्भाग्य से यह एक समारोह पाने के लिए andThen
के साथ उन्हें रचना चाहते हैं संकलित नहीं करता है :(
scala> val h = (f andThen g)
<console> error: value andThen is not a member of (Int, Int) => Int
val h = (f andThen g)
यह संकलित क्यों नहीं करता है और प्राप्त करने के लिए मैं f
और g
कैसे लिख सकता हूं?
की संभावित डुप्लिकेट [क्यों Function2 एक andthen विधि नहीं है?] (Https://stackoverflow.com/questions/21680117/why-doesnt-function2-have-an-andthen-method) – theon