Opa:如何操作stringmap(和其他贴图)
我想创建一个Stringmap,在里面添加一些值,并向它传递一些函数。我试过这个:Opa:如何操作stringmap(和其他贴图),string,map,opa,String,Map,Opa,我想创建一个Stringmap,在里面添加一些值,并向它传递一些函数。我试过这个: import stdlib.core.map mymap = StringMap_empty mymap["rabbit"] = 12 function addmap(map) { map["rabbit"] = 24 } 但是什么都没有。我只能通过数据库使用stringmap!(->数据库字符串映射(int)/myMap) 我的代码怎么了?Opa是一种函数式编程语言。有关更多信息,
import stdlib.core.map
mymap = StringMap_empty
mymap["rabbit"] = 12
function addmap(map)
{
map["rabbit"] = 24
}
但是什么都没有。我只能通过数据库使用stringmap!(->数据库字符串映射(int)/myMap)
我的代码怎么了?Opa是一种函数式编程语言。有关更多信息,请阅读此线程:
mymap = StringMap.empty
mymap = StringMap.add("rabbit", 12, mymap)
// you can't just write StringMap.add("rabbit", 12, mymap)
// because values are by default not mutable
// the function returns the map with the new element added
function addmap(map)
{
StringMap.add("rabbit", 24, map)
}
mymap = addmap(mymap)