Avoiding "variable might not have been initialized"
- by Mason Wheeler
I recently ran across a routine that looks something like this:
procedure TMyForm.DoSomething(list: TList<TMyObject>; const flag: boolean);
var
local: integer;
begin
if flag then
//do something
else local := ExpensiveFunctionCallThatCalculatesSomething;
//do something else
for i := 0 to list.Count do
if flag then
…