Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C++
#include <utility>
using std::swap;
swap(a, b);

This is the most proper way. There are plenty of other ways, but this one should be the most correct, generic and performant.
procedure swap(a, b: in out Integer)
is
    temp : Integer;
begin
    temp := a;
    a := b;
    b := temp;
end swap;

New implementation...
programming-idioms.org