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

Enumerable#each_entry と each の違いが分かりづらい #2307

Open
pocke opened this issue Jul 2, 2020 · 0 comments
Open

Enumerable#each_entry と each の違いが分かりづらい #2307

pocke opened this issue Jul 2, 2020 · 0 comments

Comments

@pocke
Copy link
Member

pocke commented Jul 2, 2020

https://docs.ruby-lang.org/ja/latest/method/Enumerable/i/each_entry.html

Enumerable#each_entry と each はとても似ているメソッドですが、 each_entry のドキュメントからはその違いが分かりづらいです。

each_entry のドキュメントには次のように書かれています。

ブロックを各要素に一度ずつ適用します。

一要素として複数の値が渡された場合はブロックには配列として渡されます。

おそらくeachとの違いは「一要素として複数の値が渡された場合はブロックには配列として渡されます。」だけなのだと思います。
ただ、この説明だとそこがeachとの差であることが読み取れませんでした。

そのため、「eachと似ているところ、違うところ」を明示的に説明する、サンプルコードを追加する、などすると、わかりやすくなるかなと思います。

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

1 participant