-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add Array#compact_map #63
Conversation
@@ -0,0 +1,17 @@ | |||
module MoreCoreExtensions | |||
module ArraySelectResult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be on Enumerable instead?
👍 for the idea, but I don't like the name... What are the other methods that do this "dual" thing. Only one I can think of is Additionally, if you have a select, you probably want a reject. |
Crystal lang uses |
Also a few of these rubocops are legit. |
9b4611f
to
3bd9c94
Compare
3bd9c94
to
ec36c0b
Compare
Checked commit bdunne@ec36c0b with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Too many times I find myself enumerating over an array wanting some transformed data and no
nil
s. So, I wind up with something like this:Instead, we can have:
This avoids allocating an extra array before the compact