Scala API 2.10.*: Function2.andThen what happened to?

我与影子孤独终老i 提交于 2019-12-05 05:54:51

I don't understand where that example is going at all, but here's some code that compiles in scala 2.10.2.

trait Cat
trait Bird
trait Catch
trait FullTummy

def `catch`(hunter: Cat, prey: Bird): Cat with Catch = ???
def eat(consumer: Cat with Catch): Cat with FullTummy = ???

val story = (`catch` _).tupled andThen (eat _)
story(new Cat with Catch, new Bird {})

I had to quote catch because it's a reserved word, and tuple the Function2.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!