Scala extends double arrow

不羁岁月 提交于 2019-12-31 02:01:07

问题


I was looking at the Anorm source code and for the RowParser trait it has the declaration:

trait RowParser[+A] extends (Row => SqlResult[A]) { ... }

I was curious what type (Row => SqlResult[A]) is? I haven't been able to find an explanation of the syntax anywhere.


回答1:


This is syntactic sugar for Function1 which is the same as this:

trait RowParser[+A] extends Function1[Row, SqlResult[A]] 

If you look further in the Anorm source you'll see that when the trait is implemented it has to define an apply function since it's implementing the Function1 trait.



来源:https://stackoverflow.com/questions/17434896/scala-extends-double-arrow

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