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

Add single shortcut for reducing single element enumerables #39549

Closed
wants to merge 1 commit into from

Conversation

rynonl
Copy link

@rynonl rynonl commented Jun 5, 2020

Summary

I frequently find myself and my team working with enumerables that we know should only contain a single element. Using #first or #last does not adequately protect against those times when the enum has length 0 or > 1, and does nothing to indicate that the enumerable is expected to have exactly 1 element.

@rynonl rynonl force-pushed the enumerable-single branch 2 times, most recently from 8285fa4 to 9625caf Compare June 5, 2020 20:06
…lement

I frequently find myself and my team working with enumerables that we know should only contain a single element. Using #first or #last does not adequately protect against those times when the enum has length 0 or > 1, and does nothing to indicate that the enumerable is expected to have exactly 1 element.
@jonathanhefner
Copy link
Member

Thank you for the pull request. I have wanted this feature on several occasions! However, this is a duplicate of #26206, which was closed because it is being discussed as an addition to Ruby itself in Ruby Issue 13683. Feel free to voice your support there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants