问题来了,
假设我们有一个数据类型和一组数据类型:
data Color=red(int n, str name)|black(int n, str name);
set[Color] coloredBalls={red(1,"a"), red(2,"b")};
我想遍历集合的元素并更改元素如下:
for(Color aColor <- coloredBalls)
{
if(aColor.n == 2)
aColor.str="bb"
//I would like to change the node: red(2,"b") to red(2,"bb") in the set coloredBalls
//but am unable to express it in Rascal, unless I recourse to using a "Map", which I
//think obfuscates the code quite a bit. Maybe using switch/visit with case does the trick?
}