You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
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 ofArray
.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).The text was updated successfully, but these errors were encountered: