uses System.SysUtils;
type
TTiger = class
Age: Integer;
constructor Create(AAge: Integer);
end;
constructor TTiger.Create(AAge: Integer);
begin
Age := AAge;
end;
//dispatch by overload, "when" guards
//are plain conditions inside
function Describe(I: Integer): string;
overload;
begin
if I > 1000000 then
Result := 'Big number'
else
Result := 'Unknown number';
end;
function Describe(const S: string): string;
overload;
begin
if Length(S) < 256 then
Result := 'Short string'
else
Result := 'Long string';
end;
function Describe(T: TTiger): string;
overload;
begin
if T.Age > 12 then
Result := 'Old tiger'
else
Result := 'Young tiger';
end;
begin
WriteLn(Describe(TTiger.Create(15)));
//printed 'Old tiger'
end.