3 ms·
Lots of these things that look like syntax problems are in fact design problems surfaced by the compiler. The `nickname` variable holds onto a reference to the
by afandian 7y ago
Lots of these things that look like syntax problems are in fact design problems surfaced by the compiler.
The `nickname` variable holds onto a reference to the substring of `name`. Subsequently `name` is modified (cleared).
This forces you to think about the behaviour. Should the nickname remain constant even if the backing `name` string changes? Probably yes, so you'd take a copy at that point.