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

Questions about arrays #8

Closed
pavellishin opened this issue Sep 25, 2019 · 1 comment
Closed

Questions about arrays #8

pavellishin opened this issue Sep 25, 2019 · 1 comment

Comments

@pavellishin
Copy link

pavellishin commented Sep 25, 2019

Howdy! I'm trying to write some patterns for a buddy's cube, and I've written something to help me test locally, but I'm still unsure of language limitations.

I see that array literals aren't permitted, but does array.length exist?
Can arrays be of variable size at all?
When you create a new array with array(10), what are the initial values of that array?

@pavellishin pavellishin changed the title More clarity in docs? Can arrays be dynamically sized? Sep 25, 2019
@pavellishin pavellishin changed the title Can arrays be dynamically sized? Question about arrays Sep 25, 2019
@pavellishin pavellishin changed the title Question about arrays Questions about arrays Sep 25, 2019
@simap
Copy link
Owner

simap commented Sep 26, 2019

The language is es6 in syntax, but a limited subset of functionality is supported. Currently there is no object support, which rules out things like array.length and constructors. Thats why the way to allocate an array is different. I suppose I should have made a function like arrayLength(array).

Arrays, once created, are of fixed length. They work more like primitive arrays in other languages, though they can store elements of any value including functions or other arrays. Accessing an element outside of the bounds of an array will abort the current function and show an error in the editor and highlight the line responsible, but rendering will continue (the show must go on!).

Arrays are initialized with zeros.

BTW, this would be a good thing to ask in the forum!

@simap simap closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants