What is the default value of 'Result' in Delphi?

Solution 1:

A function return value of type string is actually treated by the compiler as an implicit var parameter. When the function begins execution, the Result variable contains whatever is in the local variable to which the return value will subsequently be assigned.

Accordingly, you should always initialize function return values. This advice holds not only for strings, but for all data types.

This issue was discussed just yesterday here on Stack Overflow:

Do I need to setLength a dynamic array on initialization?

Solution 2:

If the function exits without assigning a value to Result or the function name, then the function's return value is undefined.

see Delphi Reference > Procedures and Functions > Function Declarations