Ownership

Other topics

Remarks:

Note that the compiler will not prevent you from using variable for which its value ownership been transfeered.

Transfer Ownership

var foo = new uint8[12];
var bar = (owned) foo;
assert (foo == null);

The bar variable will own the value previously owned by foo.

Implicit Copy

var foo = new uint8[12];
var bar = foo;
assert (foo != bar);

In this example, the both foo and bar possess a strong reference, but since uint8[] only support single ownership, a copy is made.

Contributors

Topic Id: 9075

Example Ids: 28187,28381

This site is not affiliated with any of the contributors.