vala

Ownership

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.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow