Can I define an array type of different types?
I'd like to define an array type which consists of different types, such
as String, Integer, Boolean, Double, etc. but no objects, structures, or
anything of that nature. Then I'd like to use this type as a function
argument, for example...
type
TMyArray = array of ...?...;
function GetSomething(const Input: TMyArray): String;
var
X: Integer;
begin
for X:= 0 to Length(Input) - 1 do begin
//Identify type and handle accordingly...
//Serialize data for the result...
end;
end;
and use it like...
Variable:= GetSomething(['some string', 123, 'something else', 12.3, false]);
Then, how do I identify what type each element is when iterating through
such an array?
I'm pretty sure this is possible, but have no idea even what terminology
to search for. How do I do this?
Would I have to define this as an array of Variants? Or is there a way to
define exactly which types the array accepts?
No comments:
Post a Comment