Hello. I’m trying to write a class that handles vectors, and there are some strange Array implementations that are blocking me:
Vector : FloatArray {
*new {
arg size = 2;
var v;
v = super.newClear(size);
[\sizes, size, v.size, v.maxSize].postln;
^ v;
}
I would expect if I run Vector.new(3) to create an empty Array-like object with a maxSize of 3, but instead what I get in the printout is: “[ sizes, 3, 0, 1 ]” - meaning that I asked for 3, the current size is 0, and the maxSize is 1. Using any of the other Array creation methods, like v = super.fill(size, {0}); just creates an endless loop.
What am I doing wrong here? The same behavior happens with Array, RawArray, ArrayedCollection, etc.