【发布时间】:2011-02-23 12:48:46
【问题描述】:
我在我的 scala 代码中使用 JSON 库 net.sf.json(http://json-lib.sourceforge.net/apidocs/net/sf/json/package-summary.html)。 另外,我正在使用规范 BDD 框架 (http://code.google.com/p/specs/) 进行单元测试。在 doBefore 块中,我有以下代码:
doBefore {
iter = serversJSON.iterator()
}
serversJSON 是一个 JSONArray 对象。在doBefore块之外,我已经声明了使用的变量如下
var serversJSON:JSONArray = null
var iter:Iterator[JSONArray] = null
但在编译时出现以下错误。
错误:类型不匹配;成立 : java.util.Iterator[?0] where type ?0 必需的: java.util.Iterator[net.sf.json.JSONArray] iter = 服务器JSON.iterator()
我猜我在 doBefore 之外声明 iter 对象的方式是不正确的。如何解决这个问题?
请帮忙 谢谢。
【问题讨论】: