Open NKarolak opened 3 months ago
I think the correct way would be:
procedure TestAL0603()
var
MyEnum: Enum MyEnum;
Integers: List of [Integer];
begin
MyEnum := MyEnum.FromInteger(1);
MyEnum := MyEnum.FromInteger(Integers.Get(1));
end;
But you can not use FromInteger in foreach, at least not without some (bad looking) overhead:
procedure TestAL0603()
var
MyEnum: Enum MyEnum;
MyEnumAsInt: Integer;
begin
foreach MyEnumAsInt in Enum::MyEnum.Ordinals() do begin
MyEnum := MyEnum.FromInteger(MyEnumAsInt);
end:
end;
So in my opinion, it's fine the way it is.
Bug or feature? Why is warning AL0603 raised when directly assigning an integer to
MyEnum
, and why not when assigning it indirectly inforeach
?Don't get me wrong - I prefer it without the warning. So much cleaner ... But then I see no reason why we should get AL0603 at direct assignment.
Versions: