Given the following:
Type
TSomeTypeArray = array of SomeType;
var
anArray: array of SomeType;
function GetSomeTypeArray: TSomeTypeArray;
I want to write anArray = GetSomeTypeArray(); but the compiler does not like it.
Without changing the type of anArray or the return type of GetSomeTypeArrayhow can I typecast TSomeTypeArray to array of SomeType?
You can't. You need to declare
anArrayas of typeTSomeTypeArray, then it should work.Alternatively, you could store the result into another array of type
TSomeTypeArraythen callSetLengthonanArrayto the length of the returned array. And finally loop through the two arrays setting the elements ofanArrayto the elements of the returned array.