Skip to main content

copy

Discworld driver help

copy

Name

copy() - recursively duplicate a value

Synopsis

mixed copy( mixed arg );

Description

copy() returns a value with exactly the same value as `arg', but with all reference types (mappings, arrays, etc.) duplicated. For example:

mapping a, b = ({ 1 });
a = b;
a[0] = 2;
printf("%O %O\n", a, b);

results in ({ 2 }) and ({ 2 }), while:

mapping a, b = ({ 1 });
a = copy(b);
a[0] = 2;
printf("%O %O\n", a, b);

results in ({ 2 }) and ({ 1 }).