I'm trying to compile the following code, but it falis :
import stdlib.core.map
function f()
{
stringmap(string) myM = StringMap.add("rabbit", "horse", StringMap_empty)
string rabbit= myM["rabbit"]
}
Why is that ? I have the feelling that this code was working with my previous release of opa (0.9.*).
How can I access to data stored in a StringMap ? In my code, I want to access the data return by a
HttpRequest.Generic.get_form_data(HttpRequest.request x).
Thanks
No your code can't have worked on any previous version of Opa. We already discuss about some aspects of Opa and StringMap in a previous thread you opened here: Opa : howo to manipulate stringmap (and other map)
In summary:
f
can't end with a binding like rabbit = v
.myM["rabbit"]
syntax, you have to use StringMap.get
in your case.Here is a working code:
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
}
}