0
我使用Casbah 2.5.0。有教程中的例子:如何将MongoDBList转换为BasicDBList?
scala> val builder = MongoDBList.newBuilder
scala> builder += "foo"
scala> builder += "bar"
scala> builder += "x"
scala> builder += "y"
builder.type = [email protected]
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?
谢谢。还有一个问题。有一种简单的方法将List转换为MongoDBList(或BasicDBList)? – un1t 2013-03-03 17:04:16
我更新了我的答案 – 2013-03-03 19:15:03
@SergeyPassichenko可以,请回答http://stackoverflow.com/questions/15188605/scala-casbah-how-to-convert-list-to-mongodblist以及? – 2013-03-03 19:25:26