The method element can only be invoked on a value of type set. It should only be used on a set that has exactly one element. The method then returns this element, which otherwise could only be extracted by traversing the set with forall , or using toList to turn the set into a list (and use its method last or operator [1] to fetch the element):

<result> = < set > . element ()  

<set>

A value of type se t or an expression evaluating to a value of that type.

<result>

A value of any type: the single element in the set.


When the set is empty, this method will raise an error. When the set contains more than one element, a warning is issued and the method will return one of the elements from the set.



Related articles