pascalabcnet/TestSuite/intellisense_tests/match1.pas
Бондарев Иван 7177fbe9d3 fix #861
2018-07-01 14:16:51 +02:00

22 lines
523 B
ObjectPascal

type
Line = class
end;
Rectangle = auto class
X,Y,Width,Height: real;
end;
Circle = auto class
X,Y,Radius: real;
end;
begin
var l := new List<Object>;
l.Add(new Line);
l.Add(new Circle(10,10,5));
l.Add(new Rectangle(10,10,20,10));
foreach var x in l do
match x with
Line(var ll): Println('Line S =',0);
Circle(var c): Println('Circle S =',c{@var c: Circle;@}.Radius*c.Radius*Pi);
Rectangle(var r{@var r: Rectangle;@}): Println('Rectangle S =',r.Width*r.Height);
end;
end.