Scope and lifetime

Can the caller still use the list?

Examples

Worked example

Input
A function creates a list and returns it to a caller.
Expected output
Yes.

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

The local name goes away, but the caller now has a reference to the returned list.

Back to the lesson