![]() |
|
Navigation |
Synopsis Illegal operation on an empty set.
Function
data RunTimeException = EmptyMap();
Usage
import Exception ;
Description Rascal provides many operations and functions on sets, see Rascal:Values/Set and Rascal:Prelude/Set.
This error is generated when a function or operations cannot handle the empty set.
Remedies:
Examples Import the
Set library and introduce S with an empty set as value:
rascal>import Set; ok rascal>S = {}; set[void]: {}Taking an element from an empty set gives an error: rascal>getOneFrom(S);
|rascal://Set|(1712,454,<52,0>,<76,54>): EmptySet()
at *** somewhere ***(|rascal://Set|(1712,454,<52,0>,<76,54>))
at getOneFrom(|stdin:///|(11,1,<1,11>,<1,12>))
We can also catch the EmptySet error. First import the Rascal exceptions (which are also included in Prelude )
and IO :
rascal>import Exception; ok rascal>import IO; ok rascal>try println(getOneFrom(S)); catch EmptySet(): println("Cannot apply getOneFrom to empty set"); Cannot apply getOneFrom to empty set ok ![]() |