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
builtin delete for maps and arrays #250
Conversation
special errors returned from custom builtin modules can be identified easily by wrapping and using errors package's Is() and As() method.
merge upstream
Right now Tengo does not support negative indexing into arrays. See https://github.com/d5/tengo/blob/master/objects.go#L223 and https://github.com/d5/tengo/blob/master/objects.go#L873. So I think we should remove it from this PR for consistent behavior. |
I will remove it soon you are right I missed it |
A builtin for map deletes makes perfect sense, but now that I think about it, for arrays, the go syntax of creating slices in the form |
Daniel, I thought that for a scripting language such a syntax may not be appealing; |
If tengo will have methods like |
It sounds good to me. |
Yeah splice sounds good. |
I will remove array support from delete function if you are OK. Later I am going to implement a splice builtin. Guide me please. |
Perfect! |
builtin
delete
is ready. It works like Go's delete for maps but also works for array types. delete function returns only undefined value or raises runtime error. It mutates given map or array. doc and tests are added.