Re: [Vala] two dimensional arrays



Hello,

                 في ح، 20-03-2011 عند 13:37 +0100 ، كتب Pavol Klačanský:
Why this doesn't work? I need some help with two dimensonal arrays 

class test : GLib.Object {
      struct Field {
              string name;
              string val;
      }
      
      public static int main(string[] args) {

      int row = 0, col, cols = 5;
      Field[,] results = {};

valac really doesn't like this declaration, but since you know how many
lines and columns you have, it's better to just declare them here:
        Field[,] results = new Field[10,5]
(that said, valac should complain politely instead of crashing)

        
      do {
              for (col = 0; col < cols; col++) {
                      results[row] += Field() { name = "test", val = "bug" };

And here too, you seem to be misunderstanding how multidimensional
arrays work in Vala, they have the same number of columns for every
line.

HTH,
Abderrahim




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