Here is a variation I use - I like type safety.
type
Setting = record
i: integer;
s: string;
d: double;
constructor Create(const _i: integer; _s: string; _d:double);
end;
Option = record const
One: Setting = (i:1; s:'First'; d:0.01);
Two: Setting = (i:2; s:'Second'; d:0.02);
Three: Setting = (i:3; s:'Third'; d:0.03);
class function Add(const _i: integer; _s: string; _d:double): Setting; static; // Sugar
end;
constructor Setting.Create(const _i: integer; _s: string; _d: double);
begin
i := _i;
s := _s;
d := _d;
end;
class function Option.Add(const _i: integer; _s: string; _d: double): Setting;
begin
Result := Setting.Create(_i, _s, _d);
end;
procedure Foo(const Options: TArray<Setting>);
begin
for var Option: Setting in Options
do if Option.i in [2, 4]
then Writeln(Format('i:%d s:%s d:%f', [Option.i, Option.s, Option.d]));
end;
procedure TestFoo;
begin
Foo([Option.One, Option.Two, Option.Three, Option.Add(4,'Fourth',0.04)]);
end;