我使用 Casbah 2.5.0。教程中有示例:
scala> val builder = MongoDBList.newBuilder
scala> builder += "foo"
scala> builder += "bar"
scala> builder += "x"
scala> builder += "y"
builder.type = com.mongodb.casbah.commons.MongoDBListBuilder@...
scala> val newLst = builder.result
newLst: com.mongodb.BasicDBList = [ "foo" , "bar" , "x" , "y"]
所以这里的newLst 是BasicDBList。
但是当我自己尝试时,它的工作方式不同。
scala> val builder = MongoDBList.newBuilder
scala> builder += "foo"
scala> builder += "bar"
scala> val newLst = builder.result
newLst: com.mongodb.casbah.commons.MongoDBList = [ "foo" , "bar"]
这里的 newLst 是 MongoDBList 类型。
为什么会这样?如何将 MongoDBList 转换为 BasicDBList?