[Vala] Ownership/properties
- From: "marcin saepia net" <marcin saepia net>
- To: vala <vala-list gnome org>
- Subject: [Vala] Ownership/properties
- Date: Wed, 2 Jan 2013 21:13:54 +0100
Hi all,
I have some questions related to ownership.
If I write something like this:
public string test { get { return xxx(); } }
private unowned string xxx() {
string a = "XXX";
return a;
}
I end with error:
error: Local variable with strong reference used as return value and
method return type has not been declared to transfer ownership
What is correct approach to fix this?
a)
public string test { get { return xxx(); } }
private unowned string xxx() {
weak string a = "XXX";
return a;
}
b)
public string test { owned get { return xxx(); } }
private string xxx() {
string a = "XXX";
return a;
}
??
Could anyone describe what happens with memory handling in both cases
under the hood?
Thank you
Marcin
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]