Scalaz pipe operator connected with a list method

后端 未结 2 1573
傲寒
傲寒 2021-01-22 05:14

I am a newbie to Scala, but I have some experience in using OCaml. I am thinking to adopt the pipe operator defined in Scalaz in the follo

2条回答
  •  -上瘾入骨i
    2021-01-22 05:54

    You need to pass the "thrush" combinator a function, so the following works:

    "asdf" |> length2 |> (_.length)
    

    If you want to insert line breaks, put the operator at the end of the line:

    "asdf" |>
    length2 |>
    (_.length)
    

    or the following is also valid:

    "asdf"
    .|> (length2)
    .|> (_.length)
    

提交回复
热议问题