Random Suggestion: Swap Operator <=>?

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Fri Jul 17 08:06:06 PDT 2009


Leandro Lucarella wrote:

> A more general solution is supporting tuples in the language, then you can
> do something like:
> a, b = b, a;

That's a great feature. But even if it's available, I'd use swap, because:

* I wouldn't have to mention each variable twice
* It would use move-operations rather than copy operations

Parallel assignment is still useful for other stuff, like traversing the
fibonachi sequence with two variables :-)

(a, b) <- (b, a + b);

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list