Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1445

Delphi: TArray of T versus TArray; a function can return the latter, but not the former

$
0
0

I wish I had blogged about this a lot sooner, as then far less people would use var aFoo: array of TFoo as method parameters for results that are just out parameters and could be a function result.

You cannot have array of TFoo as function result, but you can have TArray<TFoo>. The former would be an open array, the latter is a proper array type.

I see many people use var aFoo: array of TFoo with all sorts of SetLength calls before calling and inside a method where a function returning a TArray<TFoo> would be far more appropriate, both in the sense of readability and maintainability.

–jeroen


Viewing all articles
Browse latest Browse all 1445

Trending Articles