[Vala] Trouble with array length in vala 0.7.4
- From: Sam Danielson <samdanielson gmail com>
- To: Vala ML <vala-list gnome org>
- Subject: [Vala] Trouble with array length in vala 0.7.4
- Date: Mon, 29 Jun 2009 19:49:38 -0400
I am having trouble with arrays in expressions. AFAICT foo.x.length
doesn't work if x is a function or property returning an array. I
explain more in the comments of the following snippet. I couldn't find
a bug matching this exact behavior but I would like to know if anyone
else has come across this before I file it. Using 0.7.4.
void main () {
var foo = new Foo ();
// This prints the correct value, 4.
print (" a: %d\n", foo.a.length);
// These print incorrect results. Lengths are uninitialized.
print ("aprop: %d\n", foo.aprop.length);
print ("afunc: %d\n", foo.afunc ().length);
// Assignment to a temp variable. Correct again, 4.
var tmp2 = foo.afunc();
print ("afunc: %d\n", tmp2.length);
var tmp1 = foo.aprop;
print ("aprop: %d\n", tmp1.length);
}
class Foo {
public int[] a = {1,2,3,4};
public int[] aprop {
get { return a; }
}
public int[] afunc () {
return a;
}
}
-Sam Danielson
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]