-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Prefer the non-smalltalk version of enumerable methods #169
Conversation
`collect` and `detect` are the smalltalk version of these methods, most other languages use `find`, and `reduce`/`fold`/`scan`. This is consistent with the bbatsov guide, as well.
* Prefer `detect` over `find`. | ||
* Prefer `inject` over `reduce`. | ||
* Prefer `find` over `detect`. | ||
* Prefer `reduce` over `inject`. |
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.
I've never been a fan of the inject
choice. But why not fold
?
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.
Ruby does not define a fold
method.
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.
Whoops, don't know why I thought it did.
Nooooo!!! |
This feels like a case of "pick one and we'll use it", and we've already picked one. Not sure what we gain by picking the other one. (Also, |
I created a poll to settle this: https://docs.google.com/a/thoughtbot.com/forms/d/1bTGDEqSPcwhNEiyQSxrJ_HCQCUkg1wakaJji5GWtVOQ/viewform?usp=send_form |
|
Looks like @calebthompson has a doppleganger. |
Oh shit I haven't even seen this yet. |
Since there's no strong majority, and since we already have a rule, and since the whole point of our guides is that we can argue things once and never have to think about it again, and since we've already argued this: not sure why we should merge this. |
Agreed. |
Agreed. Closing. |
I know we have had some back on forth on these (e.g. #169 and #237). These preferences were fine when we could automate fixing them with RuboCop. But as we move to standard I think we should buy fully into [standard's opinion on these aliases][standard opinion]. If we don't agree with that opinion, we should discuss the issue on standard instead of in this guide. [standard opinion]: standardrb/standard#39 (comment)
collect
anddetect
are the smalltalk version of these methods, mostother languages use
find
, andreduce
/fold
. This isconsistent with the bbatsov guide, as well.