所以我有这样的元组列表:
val rooms = List(("Hi", "mom"),("hi", "dad"))
val foo = rooms.map(arg =>{
var fields = List
( new JField("greeting",arg._1),
new JField("recipient",arg._2))
new JObject(fields)})
这片土地上有很多幸福,但是当我像这样更改房间列表时:
case class Room(greeting:String, recipient:String)
val rooms = List(Room("Hi", "mom"),Room("hi", "dad"))
val foo = rooms.map(arg =>{
var fields = List
( new JField("greeting",arg.greeting),
new JField("recipient",arg.recipient))
new JObject(fields)})
我得到:
[error] <file>: type mismatch;
[error] found : scala.collection.immutable.List.type (with underlying type object List)
[error] required: List[blueeyes.json.JsonAST.JValue]
[error] new JArray(fields)
所以现在列表似乎是 Object 而不是 JField ,这是为什么呢?