4 ms·
It's "cute", I'll give you that. But what possible use could this have? Using a temp variable is MORE likely to be optimized by the compiler[1] and is FAR easie
by mcherm 14y ago
It's "cute", I'll give you that. But what possible use could this have? Using a temp variable is MORE likely to be optimized by the compiler[1] and is FAR easier for someone reading the code to understand. Using it in an interview falls into the trap of asking useless and irrelevant questions that weed out perfectly good candidates. All in all, it's a bad idea.
[1] - I don't actually know this... but I suspect that it's true.
- bhaak 14y agoYes, the answer I would like to hear is that in a high level language - if the language itself doesn't support it (e.g. in Ruby you can do 'a, b := b, a' or a parallel computing language) - you don't fight the compiler but use the correct idiom that the compiler can optimize. You can still say that if you are programming in assembler or java bytecode for optimization reasons you can do any of those stupid programming tricks.
- city41 14y agoNot to mention this approach has issues with overflow.