开发者

Is function's result always initialized? [duplicate]

This question already has answers here: 开发者_运维技巧 Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜