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

Support for Array and Map unpacking #40

Open
its-darsh opened this issue Jul 14, 2024 · 0 comments
Open

Support for Array and Map unpacking #40

its-darsh opened this issue Jul 14, 2024 · 0 comments
Labels
enhancement Contains enhancment to the interpreter postponed Will not be solved in current release
Milestone

Comments

@its-darsh
Copy link
Collaborator

its-darsh commented Jul 14, 2024

We need to be able to unpack arrays and maps (like Python for example), Syntax wise it might look like *[] and **{}

Unpacking mostly will be used to pass arguments and keyword arguments to functions from an array / map

Example:

my_func = fn (x, y) {
    println(x, y)
}

my_func(*[1, 2]) # -> 1 2
my_func(**{"x": 42, "y": 4002}) # -> 42 4002

Also, returning multiple values will return the values packed inside an array

my_func = fn () {
    return 42, 4002
}

println(my_func()) # -> [42, 4002]
println(*(my_func())) # -> 42, 4002 (after unpack)
@yhyadev yhyadev added enhancement Contains enhancment to the interpreter postponed Will not be solved in current release labels Jul 14, 2024
@yhyadev yhyadev added this to the 0.2.0 milestone Jul 14, 2024
@yhyadev yhyadev changed the title Support for array and map unpacking Support for Array and Map unpacking Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Contains enhancment to the interpreter postponed Will not be solved in current release
Projects
None yet
Development

No branches or pull requests

2 participants