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

Enumerable::Argumentable broken for .min and .max 🐛 #161

Open
anithri opened this issue Feb 21, 2015 · 1 comment
Open

Enumerable::Argumentable broken for .min and .max 🐛 #161

anithri opened this issue Feb 21, 2015 · 1 comment
Milestone

Comments

@anithri
Copy link
Contributor

anithri commented Feb 21, 2015

The implementation of Enumerable::Argumentable is broken for methods with an .arity of -1 such as .min and .max

In both cases the method has a variable number of arguments which makes it .arity = -1. Given the way Argumentable works for arity -1 the method always passes the single argument to the min method, and passes nothing to the each resulting it taking the X smallest values of the given and unchanged array

The offending code is here

@anithri
Copy link
Contributor Author

anithri commented Feb 21, 2015

These are the affected methods

# 2.2.0
Enumerable.instance_methods.
                    map{|m| [m, Enumerable.instance_method(m).arity]}. 
                    select{|e| e.last < 0}.
                    map(&:first)
# => [:to_a, :entries, :to_h, :count, :find, :detect, :find_index, :inject, :reduce, :first, :min, :max, :min_by, :max_by, :each_with_index, :reverse_each, :each_entry, :zip, :cycle, :chunk, :slice_before, :slice_after, :to_set] 
# That's 23 methods out of 52 total.

@trans trans added this to the 3.1.0 milestone Feb 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants