Skip to content

Conversation

@GeorgeTaveras1231
Copy link
Contributor

Proposal at #4039

TODO:

  • Implement Stream.with_index/2

@josevalim
Copy link
Member

Thank you @GeorgeTaveras1231! I have added a comment, we also need tests and we are good to go.

Copy link
Member

Choose a reason for hiding this comment

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

It'd better to use defaults: offset \\ 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lexmag I was considering doing this but not sure what the benefit is, would you mind explaining your POV?

Copy link
Member

Choose a reason for hiding this comment

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

@GeorgeTaveras1231 technically it is completely the same what you've done, but obviously less code and that's the common practice throughout codebase (I believe it is true for every Elixir project), thus there is no reason not to use it. :bowtie:

Copy link
Member

Choose a reason for hiding this comment

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

The benefit is what it would be considered one function, which is useful in the documentation. For example, in your current patch, you are only documenting with_index/1, with_index/2 would show with no documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Otherwise with current patch extra body-less function needs to be defined. Even this won't combine them for docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, thank you guys :)

@josevalim
Copy link
Member

We also need to change Stream.with_index. :)

@GeorgeTaveras1231
Copy link
Contributor Author

Thank you for the feedback @josevalim @lexmag! I will address the concerns some time today.

@GeorgeTaveras1231 GeorgeTaveras1231 force-pushed the feature/Enum.with_index/2 branch from b5e8e2d to 7250002 Compare December 3, 2015 14:28
Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, forgot to update the signature in the spec

This removes the previous implementation `Enum.with_index/1` but
maintains backwards compatibility by providing a default offset of 0

Proposal at elixir-lang#4039
@GeorgeTaveras1231 GeorgeTaveras1231 force-pushed the feature/Enum.with_index/2 branch from 7250002 to 2d58208 Compare December 3, 2015 14:41
This removes the previous implementation `Stream.with_index/1` but
maintains backwards compatibility by providing a default
offset of 0
@GeorgeTaveras1231
Copy link
Contributor Author

@josevalim @lexmag what do you think?

josevalim added a commit that referenced this pull request Dec 3, 2015
@josevalim josevalim merged commit 609e042 into elixir-lang:master Dec 3, 2015
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

@GeorgeTaveras1231 GeorgeTaveras1231 deleted the feature/Enum.with_index/2 branch November 5, 2017 14:59
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.

3 participants