Navigation
Synopsis Literal in abstract pattern.
Description A literal of one of the basic types Boolean, Integer, Real, Number, String, Location, or DateTime can be used as abstract pattern. A literal pattern matches with a value that is identical to the literal.
Examples A literal pattern matches with a value that is equal to it:
rascal>123 := 123
bool: true
rascal>"abc" := "abc"
bool: true
A literal pattern does not match with a value that is not equal to it:
rascal>123 := 456
bool: false
rascal>"abc" := "def"
bool: false
A literal pattern should be of the same type as the subject it is matched with:
rascal>123 := "abc";
|stdin:///|(7,5,<1,7>,<1,12>): Expected int, but got str
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.