adambeynon/opal — Issue #45: NativeArray to support Subclassing Arrays
Author: adambeynon
Created: 2011-12-23 17:14:02+00:00
State: open
Labels: 0.4.0, discuss, feature, speed

Currently subclassing arrays breaks because subclass instances wont be real js arrays, therefore their length property will not update to reflect the true length. To fix this, js arrays will be instances of `NativeArray`, which is a ruby subclass of `Array`. `NativeArray` will re-implement all the methods that need auto updating .length properties with methods that assume they can update. This means that subclassing Array in ruby will give you methods that will check for the length property in relevant methods, and NativeArray will keep native js arrays nice and fast.

To summarise; NativeArray will re-implement around 10 Array methods that will fix this gap (and be faster than checking `.length` each time).