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

Implement Array#minmax to replace Enumerable#minmax #2199

Merged
merged 4 commits into from
Jan 4, 2021

Conversation

chrisseaton
Copy link
Collaborator

@chrisseaton chrisseaton commented Dec 23, 2020

By Maple, but not pinging here as she's on leave.

Shopify#1

wildmaples and others added 4 commits December 23, 2020 17:02
Array#minmax was not implemented so it was deferring to
Enumerable#minmax, which iterates over the array. By implementing
Array#minmax, with #min and #max, performance is improved.
`Array#minmax` doesn’t support the `n` parameter in the same way that
`#min` and `#max` do, so we shouldn’t accept it here.

Before:

```
>> array = (1..10).entries
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>> smallest, largest = array.minmax(3)
=> [[1, 2, 3], [10, 9, 8]]
>> smallest
=> [1, 2, 3]
>> largest
=> [10, 9, 8]
```

After:

```
>> array = (1..10).entries
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>> smallest, largest = array.minmax(3)
ArgumentError (wrong number of arguments (given 1, expected 0))
```
@eregon eregon added the in-ci The PR is being tested in CI. Do not push new commits. label Jan 4, 2021
@eregon eregon self-assigned this Jan 4, 2021
@graalvmbot graalvmbot merged commit abbcb82 into oracle:master Jan 4, 2021
@chrisseaton chrisseaton deleted the array-min-max branch August 30, 2021 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-ci The PR is being tested in CI. Do not push new commits. oca-signed shopify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants