type
TTiger = class
end;
//用 "is" 做运行时类型检查
function Describe(Obj: TObject): string;
begin
if Obj = nil then
Exit('Empty value');
if Obj is TTiger then
Exit('Tiger!!!');
Result := 'Unknown type';
end;
var
Expression: string;
begin
WriteLn(Describe(TTiger.Create));
//输出 'Tiger!!!'
WriteLn(Describe(nil));
//输出 'Empty value'
//case 只适用于序数类型,
//字符串要用 if/else 匹配
Expression := '3*3';
if Expression = '3 + 3' then
WriteLn('result = 6')
else if Expression = '3*3' then
WriteLn('result = 9')
else
WriteLn('unknown');
end.