我正在尝试编译以下代码,但它是falis:
import stdlib.core.map
function f()
{
stringmap(string) myM = StringMap.add("rabbit", "horse", StringMap_empty)
string rabbit= myM["rabbit"]
}
为什么?我对此代码与我之前发布的opa(0.9。*)一起使用感到非常满意。
如何访问存储在StringMap中的数据?在我的代码中,我想通过
访问数据返回HttpRequest.Generic.get_form_data(HttpRequest.request x).
由于
答案 0 :(得分:2)
没有您的代码无法使用任何以前版本的Opa。我们已经在您在此处打开的先前主题中讨论了Opa和StringMap的某些方面:Opa : howo to manipulate stringmap (and other map)
总结:
f
不能以rabbit = v
之类的绑定结束。myM["rabbit"]
语法,您必须在案例中使用StringMap.get
。这是一个有效的代码:
import stdlib.core.map
function f()
{
stringmap(string) myM = StringMap.add("rabbit", "horse", StringMap_empty)
match (StringMap.get("rabbit", myM)) {
case {none}: "not found"
case {some:value}: value
}
}