Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Java
T tmp = a;
a = b;
b = tmp;

This assumes a and b are of type T.
T may be a class or a primitive type.
procedure swap(a, b: in out Integer)
is
    temp : Integer;
begin
    temp := a;
    a := b;
    b := temp;
end swap;

New implementation...
programming-idioms.org