Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
generic function replace<T>(var X: T; NewValue: T):T;
begin
  Result := X;
  X := NewValue;
end; 

begin
  x := someoldvalue;
  y := specialize replace<TSomeType>(x, somenewvalue);
end.
utility
std::exchange(x, v);
old, x = x, new
no strict 'vars';
($old,$x) = ($x, $new);
use strict;

my $old;
my $new = 'new thing';
my $x = 'old thing';

($old,$x) = ($x, $new);
old, x = x, new
old, x = x, new
std::mem::replace(&mut x, v);

New implementation...
< >
pi