[chuck-users] .cap() for multi-dimensional arrays

Martin Ahnelöv operagasten at gmail.com
Mon Oct 1 04:57:29 EDT 2007

mån 2007-10-01 klockan 06:47 +0200 skrev Kassen:
> Fellow ChucKists....
> First; .cap() for multi-dimensional arrays isn't documented but works.
> If we have this;
> int foo[3][5];
> then this;
> <<<foo.cap()>>>;
> will return "3". We can get the 5 by using this; 
> <<<foo[0].cap()>>>;
> Other numbers then 0 are also supported as long as it smaller then
> foo.cap() (otherwise we get a array out of bound error) so 0 is
> safest.
> Next up; is this correct? The need for that "0" strikes me as rather
> in-elegant but omitting it results in a syntax error. 

Eh? What are you... Hm... Okay, I can see your point now. You're right.
Since we are dealing with arrays, every array inside foo[i] will be of
equal length; it's not like we are dealing with lists where every slot
is just a reference to another object.

Good thinking there.


More information about the chuck-users mailing list