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

How do you add an item to an array? #4

Closed
exebook opened this issue Oct 25, 2017 · 1 comment
Closed

How do you add an item to an array? #4

exebook opened this issue Oct 25, 2017 · 1 comment

Comments

@exebook
Copy link

exebook commented Oct 25, 2017

var a = [1,2,3];
a.push(4);

Uncaught Exception: <AttributeError('[1, 2, 3]' has no attribute 'push')> 
  at <module 'main'>
@zhicheng
Copy link
Contributor

add an item to array is append, here is the demo.

var a = [1,2];
print(a);
a.append(3);
print(a);
a.append(4,5,6); // you can also add multiple item at once
print(a);
a.pop();  // remove last object
print(a);
print(a.__length__());  // the count of items

you may want join mailing-list of lemon, https://groups.google.com/d/forum/lemon-lang

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