我开始玩Scala,在播放框架页面做一些例子时,我发现了一些我无法解决的问题。我在Scala很新,所以我请原谅。
为什么这个编译没有错误:
case class Location(lat: Double, long: Double)
implicit val locationReads: Reads[Location] = (
(JsPath \ "lat").read[Double] and
(JsPath \ "long").read[Double]
)(Location.apply _)
但是这个不会编译:
case class Location(lat: Double)
implicit val locationReads: Reads[Location] = (
(JsPath \ "lat").read[Double]
)(Location.apply _)
并显示错误:
使用替代方法读取重载的方法值: [错误](t:Double)play.api.libs.json.Reads [Double] [错误](隐式r:play.api.libs.json.Reads [Double])play.api.libs.json.Reads [Double] [错误]无法应用于(Double => biz.JsonProtocol.Location) [错误](JsPath \“lat”)。读取[Double]