How can I create a set containing a loc, int and string? In the example below it seems my map is converted to the container type ' value'. I would like to use the characteristics of a set; Only one element should be contained in the set and the order does not matter . In the example below the same elements are contained in what I was hoping to be a set.
rascal>mySet = ();
map[void, void]: ()
rascal>mySet += {<|project://Test/|, 1, "test"> };
value: {
(),
<|project://Test|,1,"test">
}
rascal>mySet += {<|project://Test/|, 1, "test"> };
value: {
<|project://Test|,1,"test">,
{
(),
<|project://Test|,1,"test">
}
}
Thank you again for advise :-)
Something weird is going on . First mySet is a map, and then you add a set to it and the variable mySet
is suddenly a set that contains the previous map and the new element you added. It looks to me that +=
has a bug.
If you want to add several elements to a set, you should start with a set and add elements to it like so:
rascal>mySet = { |project://Test| ,1, "test" }; // simply create the set with 3 different elements in it
set[value]: { |project://Test| ,1, "test" }
Or you could start with an empty set and add elements:
rascal>mySet = {};
set[void]: {}
rascal>mySet += 1;
set[int]: {1}
rascal>mySet += |project://Test|;
set[value]: {1, |project://Test|}
rascal>mySet += "test";
set[value]: {1, |project://Test|, "test"}