NAME

copy - create a shallow (non-recursive) copy of a value

SYNOPSIS

val.copy()

DESCRIPTION

The copy method creates a shallow (non-recursive) copy of a value. This is the same as the @ operator.

Note that the copy method is used to overload the @ operator.

RETURN VALUE

A new copy of the value

ERRORS

None

EXAMPLE

    a = [1,2,3]
    b = a.copy()
    b[1] = 20
    a
1 2 3

    b
1 20 3

    // The copy method is used to overload the "@" operator
    class foo {
        var a;
        public proc create(arr) { a = arr; }
        public proc copy() {
            "Copying!\n";
            return new foo(a);
        }
    }
    x = new foo("hello")
    y = @x
Copying!

SEE ALSO

deepcopy