Hier noch ein paar mehr Beispiele:
Delphi-Quellcode:
program Project11;
{$APPTYPE CONSOLE}
type
TMyEnum = (uno, dos, tres);
TMyRange = 10..20;
var
someBoolean: Boolean;
someEnum: TMyEnum;
someRange: TMyRange;
begin
someBoolean := Boolean(99);
someEnum := TMyEnum(99);
someRange := TMyRange(99);
WriteLn(someBoolean);
WriteLn(Ord(someEnum));
WriteLn(someRange);
Readln;
end.
Siehe auch:
Zitat:
Whichever way you look at it, range checking is fundamentally flawed as a mechanism for identifying fundamental, static errors in code, and has some very nasty smells about it in the Delphi implementation in particular.
http://www.deltics.co.nz/blog/posts/2344