Would be nice to have the following method in Spring.pas: function TArray.Create<T>(const AValues: TArray<T>): TArray<T>; begin Result := AValue; end;
From a first look maybe it looks useless, but when it comes to constant dynamic array which were added in XE7 (if I am not wrong) this makes more sense.
So the case is when I want to set certain properties say for multiple objects i can create a method like (for example): procedure SetHint(const AControl: TArray<TButton>); And I can call it like SetHint([Button1, Button2]). Or other solution is to define the local variable "LButtons" and then assign it the [Button1, Button2] and then do the FOR IN statement.
But with TArray.Create we can do it in the shortest way!
for LButton in TArray.Create<TButton>([Button1, Button2]) do
where Delphi is not yet so smart to allow (for known reasons): for LButton in [Button1, Button2] do
The example is artificial, of course it's just about using the constant dynamic array immediatly for the for in loop or other places where you need enumerable etc.
Thanks for your time.