[Vala] Array element assignment



Jurg,

    Thanks for all your help with the List objects.  I'm now trying to use simple arrays in another part of my program because I need random element access and not just sequential.  When I try to assign an element of an array I keep getting an unsupported lvalue in assignment error.  My simple test case is as follows:

using GLib;

namespace Test5 {

        public class TestClass {

                public int [] values = new int[5]();

                public void assign_values() {

                       // Here is where I get the errors.
                        values[0] = 1;
                        values[1] = 2;
                        values[2] = 3;
                        values[3] = 4;
                        values[4] = 5;

                }
        }

        public static void main(string[] args) {

                TestClass t = new TestClass();
                t.assign_values();
                foreach(int x in t.values) {
                        stdout.printf("%d\n",x);
                }
        }
}

Maybe I've been staring at the screen too long, but I can't seem to see what I'm doing wrong.   This is a simplified example, what I need to do is deep copy a subset of values from one array into another.

Cayle



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]