3 ms·
Problem is, when would you ever do any of that in the real world? Has anybody ever needed to reverse a string in place since the 80s? (Demo scene excluded of
by Stormbringer 16y ago
Problem is, when would you ever do any of that in the real world?
Has anybody ever needed to reverse a string in place since the 80s? (Demo scene excluded of course, they swallowed a different colour pill from the rest of us)
I'm aware for instance of the XOR trick to swap to variables in place. I think I used it once in the last ~20 years, and really only then because I was being pleased with my excessive cleverness.
These days I wouldn't bother, because it would just make the code fractionally harder to read, it makes for a speed-bump for the mind, whereas spelling it out with a temporary variable lets your brain keep cruising at interstate speeds.