What are the reasons to use TArray instead of Array of T?

前端 未结 3 1754
青春惊慌失措
青春惊慌失措 2020-12-03 02:53

I\'m migrating a legacy Delphi application to Delphi-XE2, and I\'m wondering if there\'s a good reason to replace the arrays defined as Array of MyType to

3条回答
  •  無奈伤痛
    2020-12-03 03:08

    It comes in handy for function results.

    Example:

    The following is not allowed in Delphi. You need to declare a separate type here. What a waste of time.

    function MyFunc:array of integer; 
    begin
    end;
    

    Wait, generics to the resque:

    function MyFunc:TArray;
    begin
    end;
    

提交回复
热议问题