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
Enhanced RDoc for Enumerable #4910
Conversation
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.
Looks good. One small typo fix, then it can be committed without further review.
enum.c
Outdated
* <i>enum</i> that correspond to the minimum and maximum values respectively | ||
* from the given block. | ||
* Returns a 2-element array containing the elements | ||
* for which the block returns minimum an maximum values: |
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.
minimum an maximum
-> minimum and maximum
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.
Done.
* With a block given and no argument, | ||
* returns the maximum element as determined by the block: | ||
* | ||
* %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" |
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.
suggestion:
{foo: 0, bar: 1, baz: 2}.max {|pair1, pair2| pair1[1] <=> pair2[1] }
# => [:baz, 2]
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.
Added.
* returns an array containing the first +n+ maximum elements that exist, | ||
* as determined by the block. | ||
* | ||
* %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] |
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.
suggestion:
{foo: 0, bar: 1, baz: 2}.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] }
# => [[:baz, 2], [:bar, 1]]
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.
Added.
* With a block given, returns the minimum and maximum elements | ||
* as determined by the block: | ||
* | ||
* %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] |
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.
suggestion:
{foo: 0, bar: 1, baz: 2}.minmax {|pair1, pair2| pair1[1] <=> pair2[1] }
# => [[:foo, 0], [:baz, 2]]
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.
Added.
Thanks, @JuPlutonic, I will look at these comments. |
Treats: