为什么在Scala Play JSON Combinators中format combinator不需要下划线

为什么在Scala Play JSON Combinators中format combinator不需要下划线,scala,playframework,Scala,Playframework,我在这里找到了一个关于阅读[T]的很好的解释: 我不完全理解的一件事是,为什么格式[t]不要求生物使用下划线。请在此处应用: import play.api.libs.json._ import play.api.libs.functional.syntax._ implicit val creatureFormat = ( (__ \ "name").format[String] and (__ \ "isDead").format[Boolean] and (__ \ "wei

我在这里找到了一个关于阅读[T]的很好的解释:

我不完全理解的一件事是,为什么格式[t]不要求生物使用下划线。请在此处应用:

import play.api.libs.json._
import play.api.libs.functional.syntax._

implicit val creatureFormat = (
  (__ \ "name").format[String] and
  (__ \ "isDead").format[Boolean] and
  (__ \ "weight").format[Float]
)(Creature.apply, unlift(Creature.unapply))  
但如果这只是一个简单的例子

import play.api.libs.json._
import play.api.libs.functional.syntax._

implicit val creatureReads = (
   (__ \ "name").read[String] and
   (__ \ "isDead").read[Boolean] and
   (__ \ "weight").read[Float]
 )(Creature.apply _)

读取不“需要”吗?在我的代码中,混合使用了基于它们的Reads[T]和Format[T]模型,这让我思考了为什么会有不同

\uu
在方法之后表示部分应用

当您需要将方法转换为函数时,这是必需的

大多数情况下,您可以跳过
,因为编译器能够从上下文中推断出这一点,并自动将方法扩展为函数

因此,在这两种情况下,您都可以删除