Fellow ChucK users:  can anyone comment on the possibility of achieving a
ragged object array in ChucK?  By ragged array, I mean an array of arrays
of Objects as opposed to a 2D array.

The docs state that an array is an Object, so it's within the realm of
possible, by my current guess is that it's not possible to cast an Object
to an array so that I can invoke, eg, it's size method.

Any comments appreciated!
Thanks in advance, Dana

Here's some not-quite working code:

// this part works.
Object @ meta[]; // an array of arrays of objects (ragged)
for(int i;i<10;i++)
{
    Object subarray[0];
    meta << subarray;
}

// here's the problem:

// Object  has no method size() (compile-time failure)
// <<< "element[2] size: " , meta[2].size() >>>;

// so the solution must involve a cast operation
// but this produces a syntax error
(meta[2] $ Object[]) @=> Object a[];
<<< a.size() >>>;
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

Reply via email to