Navigation
Synopsis Add an element to a set.
Syntax Exp1 + Exp2
Types
Exp1 Exp2 Exp1 + Exp2
set[T1] T2 set[lub(T1,T2)]
T1 set[T2] set[lub(T1,T2)]
Description The + operator will add elements to sets.
Examples
rascal>{1, 2, 3} + 4;
set[int]: {1,2,3,4}
rascal>1 + { 2, 3, 4};
set[int]: {1,2,3,4}
rascal>{1} + 1;
set[int]: {1}
rascal>1 + {1};
set[int]: {1}
Pitfalls
  • if both operands of + are a set then it acts as Union.

Questions
Question [1]. When you insert an element in a set, the number of elements in the result is always:




Question [2].
The type of 6 + {63, 64, 89} is

Question [3].
86 + {10, 46} == 

Question [4].
{"Coconut", "Slimey the Worm", "Gooseberry", "W", "Apple"} + "Celery" == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.