Skip to content

Conversation

@dmitrykleymenov
Copy link
Contributor

It wasn't available to define arguments order in fun from docs and doctests, so I think it should be said excplicitly

## Examples
iex> Enum.scan(["a", "b", "c", "d", "e"], &(&1 <> String.first(&2)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking we should use fn elem, acc -> in those examples for clarity. WDYT?

Copy link
Contributor Author

@dmitrykleymenov dmitrykleymenov May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it and even my first attempt was to do so, and I think in the new example & is ok, but for existed one fn version seemed better, since + isn't affected by the order of arguments and it's better to explicitly point out where acc and element are

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we general we should prefer fn for documentation, in case someone is new to the language and they have not mastered the & notation yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable, will back with changes

@josevalim josevalim merged commit 945c057 into elixir-lang:main May 20, 2025
11 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Nezteb pushed a commit to Nezteb/elixir that referenced this pull request Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants