Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is function's result always initialized? [duplicate]

Tags:

types

delphi

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?

like image 756
pop32 Avatar asked Nov 16 '25 05:11

pop32


1 Answers

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.

like image 124
David Heffernan Avatar answered Nov 18 '25 20:11

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!