It is now possible to use the enum this way:
class Main
{
static function main()
{
var t = And([
TestText(???name??™, Same, ???John??™),
TestText(???lastname??™, Same, ???Doe??™),
Or([
And([
TestIsNull(???age??™),
TestText(???notes??™, Like, ???%authorized%??™),
]),
TestNumber(???age??™, MoreThan, 18)
])
]);
trace(QueryTools.toSql(t));
}
}
138
Part I: The Core Language
That will nicely trace:
(name = ???John??™ AND lastname = ???Doe??™ AND ((age IS NULL AND notes LIKE
???%authorized%??™) OR age > 18))
It is important to note that using switch is the only available way to extract the values associated to a
constructor without having to recur on Reflection (see Chapter 16 for details).
As already seen for other types, enum s can also use type parameters. Here ??™ s a short example to point
it out:
enum ValueStatus < T >
{
NonExistent;
Unknown;
Known(value : T);
}
Take a look at Chapter 16 in the ??? Reflection API ??? section to learn how to retrieve the index of an enum
constructor; it is quite obvious that when you want to use the enum indexes their position in the type
declaration is relevant: The first constructor declared has index zero and the index value is incremented
by one for each subsequent constructor.
Pages:
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283