Is it necessary to assign a default value to a variant returned from a Delphi function?
Gradually I've been using more variants - they can be very useful in certain places for carrying data types that are not known at compile time. One useful value is UnAssigned ('I've not got a value for you'). I think I discovered a long time ago that the function: function DoSomething : variant; begin If SomeBoolean then Result := 4.5 end; appeared to be equivalent to: function DoSomething : variant; begin If SomeBoolean then Result := 4.5 else Result := Unassigned; // <<<< end; I presumed this reasoning that a variant has to be created dynamically and if SomeBoolean was FALSE, the compiler