Possible Duplicate:
What is the default value of Result in Delphi
Similar to this question, I now ask the following.
function Test:Boolean;
begin end;
Is the result value always guranteed to be false(0)? Integer values are not, so are booleans?
No, if you don't initialise a value type function result then it's value is undefined. It could be False (0), True (1), or indeed some other integer value.
You can view a function return variable in the same light as a local variable which of course need to be initialized before use.
The moral of the tale? Always initialize your function return values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With