Server Administration

A script stores a destination in reportPath; a helper changes its own local variable with the same name, leaving the caller's destination unchanged. How should the helper's destination be passed back for the caller to use?

Show the answer

Correct answerD. Return the destination and assign it to reportPath

AWhy not this: Repeated calls still modify only the helper's local variable.

BWhy not this: Deleting a local value does not assign that value to the caller's variable.

CWhy not this: A comparison evaluates values but does not transfer the helper's destination to the caller.

DWhy this is right: Returning the value and assigning it in the caller updates the variable the caller actually uses.

Returning the destination and assigning it to the caller's reportPath explicitly transfers the value across scopes. Repeating the helper call still changes only its local variable, not the caller's variable.