Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Rust
std::mem::swap(&mut a, &mut b);
let (a, b) = (b, a);

This uses pattern matching and destructuring of tuples to swap values.
procedure swap(a, b: in out Integer)
is
    temp : Integer;
begin
    temp := a;
    a := b;
    b := temp;
end swap;

New implementation...
programming-idioms.org