[chuck-users] Question about Arrays

Mike McGonagle mjmogo at gmail.com
Mon Jan 9 12:42:00 EST 2006

Hello All,

I was wondering how I could, once an array has been defined and given
a size, how can I recreate this array with a new size as an empty
array. Basically, what I am trying to do is to take one array and
temporarily store it in another array for later recall.

I am creating an object that will extend another, but I want this
functionality to reside in the parent object, and the subclasses may
have different sizes for these arrays.

public class BaseClass {
   float myArray[];
   float myStoreArray[];

   fun void backUpArray() {
      myStoreArray[myArray.cap()];  // this is the line in question
      for (0 => int i; i < myArray.cap(); i++) {
         myArray[i] => myStoreArray[i];

public class SubClass extends BaseClass {
   fun void assignMyArray(float a, float b, float c, float d) {
      [a, b, c, d] @=> myArray;

public class SubClass2 extends BaseClass {
   fun void assignMyArray(float x, float y, float z) {
      [x, y, z] @=> myArray;

SubClass sub1;
SubClass2 sub2;

sub1(0.4, 0.6, 1.5, 2.6);
sub2(37.2, 23.4, 53.2);



I hope this makes sense.



More information about the chuck-users mailing list