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

Enhanced RDoc for Enumerable #4910

Merged
merged 2 commits into from Sep 29, 2021
Merged

Enhanced RDoc for Enumerable #4910

merged 2 commits into from Sep 29, 2021

Conversation

BurdetteLamar
Copy link
Member

Treats:

  • #min
  • #max
  • #minmax
  • #min_by
  • #max_by
  • #minmax_by
  • #include?

@BurdetteLamar BurdetteLamar added the Documentation Improvements to documentation. label Sep 29, 2021
Copy link
Contributor

@jeremyevans jeremyevans left a 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:
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@BurdetteLamar BurdetteLamar merged commit 49edaa0 into ruby:master Sep 29, 2021
* 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"
Copy link

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]

Copy link
Member Author

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"]
Copy link

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]]

Copy link
Member Author

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"]
Copy link

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]]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@BurdetteLamar
Copy link
Member Author

Thanks, @JuPlutonic, I will look at these comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements to documentation.
3 participants