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

配列のmapなどのコールバック関数が受け取るインデックスが1から始まっている #235

Closed
salano-ym opened this issue Feb 13, 2023 · 0 comments · Fixed by #236

Comments

@salano-ym
Copy link
Member

salano-ym commented Feb 13, 2023

配列のmap, filter, reduce, findに渡すコールバック関数の引数でインデックスが受け取れるが、0ではなく1から始まっている。
バージョン1.12.0で配列のインデックスが0始まりに変更されているため、それに合わせた方がいい?
既存コードへの影響を考慮して維持するか別の関数にする?

[0 1 2].map(@(v i) {
  print(i) // 1 2 3
})
@salano-ym salano-ym changed the title 配列のmapなどの関数で受け取るインデックスが1から始まっている 配列のmapなどのコールバック関数が受け取るインデックスが1から始まっている Feb 13, 2023
salano-ym added a commit to salano-ym/aiscript that referenced this issue Feb 13, 2023
salano-ym added a commit to salano-ym/aiscript that referenced this issue Feb 13, 2023
salano-ym added a commit to salano-ym/aiscript that referenced this issue Feb 13, 2023
syuilo pushed a commit that referenced this issue Mar 11, 2023
* add tests (#235)

* arr map index starts with 0 (#235)
filter, reduce, find

* update CHANGELOG.md (#235)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant