A class cannot extend the primitive type X |
|
Classes correspond to properties of values, and primitive types are not such properties, so you cannot use them as a base type for a class.
Example error and correction
class ABC extends string {
ABC() {this="A" or this="B" or this="C"}
string toString(){result="ABC"}
}
Saying that a value is a string is not a real constraint from the point of view
of solving a query, as there are an infinite number of strings. Therefore to
say that a class extends string is wrong. In the above example, it is
actually superfluous: if we want a class ABC that captures just the
values "A", "B" and "C", we just leave off the extends clause:
class ABC {
ABC() {this="A" or this="B" or this="C"}
string toString(){result="ABC"}
}
|