Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeArray to support Subclassing Arrays #45

Closed
adambeynon opened this issue Dec 23, 2011 · 2 comments
Closed

NativeArray to support Subclassing Arrays #45

adambeynon opened this issue Dec 23, 2011 · 2 comments

Comments

@adambeynon
Copy link
Contributor

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).

@ghost ghost assigned adambeynon Dec 23, 2011
@adambeynon
Copy link
Contributor Author

Indeed Native::Array might be better.

@adambeynon
Copy link
Contributor Author

This is fixed by 71741d4, which uses a different approach to fix array subclassing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant