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

Passing value type functions to the arrow function #20

Open
ppaska opened this issue Feb 4, 2021 · 0 comments
Open

Passing value type functions to the arrow function #20

ppaska opened this issue Feb 4, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@ppaska
Copy link
Contributor

ppaska commented Feb 4, 2021

This code doesn't work

x = [1, 2,3,4,5,6]
sum = 0
f.forEach(v => sum = sum + v)
print(sum) # incorrect sum will be here

# workaround is to add it to the object. e.g.

sum = {value: 0}
f.forEach(v => sum.value = sum.value + v)
print(sum.value) # correct sum will be here
@ppaska ppaska added the bug Something isn't working label Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant