I can use scalaz
|>
operator when I want to switch function and object so there can be a little more readability acquired. Let me introduce you a model function :
def length2(x:String) = x.length * 2
Now, I can write it in both ways:"aoeu" |> length2
length2("aoeu")
But if I define this function more generic, it stops working.def length2(x:SeqLike[_
,_
]) = x.length * 2
length2("aoeu") // ok
"aoeu" |> length2 // doesn't work
Why the compiler doesn't understand this? There is definitely an implicit conversion from String
to some class mixing in trait SeqLike
.