How to cast a value type to Map in Rascal?

点点圈 提交于 2019-12-07 11:32:01

问题


I have a variable of type value that stores a map, but I can not access the values by providing the keys:

rascal>a
value: ("s":"s")

rascal>a["s"]
|stdin:///|(2,3,<1,2>,<1,5>): subscript not supported on value at |stdin:///|(2,3,<1,2>,<1,5>)
☞ Advice

How can I parse the value to map in order to be able to retrieve my value ?


回答1:


if (map[str,str] myMap := a) {
   // do stuff with myMap
}
else {
  throw "<a> is not a map?";
}


来源:https://stackoverflow.com/questions/20221445/how-to-cast-a-value-type-to-map-in-rascal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!