Sets
Unlike many other languages, OneScript supports the ability to store, combine and test options that may represent options selected by recipient of a survey. The Set type takes the following basic form:
{ident[,ident]}
For example:
{a,b,c}
Sets do not support whitespace between the ident values.
It is possible to combine sets for example:
Set e1 = {a,b,c};
Set e2 = {g,h,i};
e1 = e1 + {d}; // Result is {a,b,c,d}
e1 = e1 - {a}; // Result is {b,c,d}
e1 = e1 + e2; // Result is {b,c,g,h,i}
It is also possible to test whether a Set is present in a value is:
Set e1 = {a,b,c};
Set e2 = e1 & {a}; // Result is {a}
e2 = e1 & {h}; // Result {}
e2 = e1 | {h}; // Result is {a,h}
Sets are case insensitive:
Set e1 = {A,b,c};
Set e2 = {g,h,i};
e1 = e1 + {D}; // Result is {a,b,c,D}
e1 = e1 - {a}; // Result is {b,c,d}
e1 = e1 + e2; // Result is {b,c,g,h,i}
Last updated