Compose and andThen methods

后端 未结 4 423
长情又很酷
长情又很酷 2021-01-30 08:28

I\'m following the tutorial Pattern matching & functional composition on Scala compose and andThen methods. There\'s such an example:

4条回答
  •  时光取名叫无心
    2021-01-30 09:11

    From compose documentation:

    Composes two instances of Function1 in a new Function1, with this function applied last.

    so you should write

    scala> val ummThenAhem = (addAhem _).compose(addUmm _)
    ummThenAhem: String => java.lang.String = 
    

    to treat addAhem and addUmm as partially applied functions (i.e function1)

    scala> addAhem _
    res0: String => java.lang.String = 
    

提交回复
热议问题