Skip to content

[Bug #21106] Remove the useless last iteration in Array#shuffle #12690

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

Merged
merged 3 commits into from
Feb 2, 2025

Conversation

nobu
Copy link
Member

@nobu nobu commented Feb 2, 2025

When only one element remains, this simply swaps the first identical element and has no actual effect.

nobu added 2 commits February 2, 2025 19:34
When only one element remains, this simply swaps the first identical
element and has no actual effect.
When a positive integer limit is given, `rand` method of a RNG object
is expected to return a value between 0 and the limit (exclusive).

Fix shuffle_spec.rb like as the similar code in sample_spec.rb, and
add tests for greater values.

TODO:
- Return a value that is equal to or greater than the limit given to
  the RNG object.
- Extract common code about RNG objects to a shared file.

This comment has been minimized.

@matzbot matzbot merged commit 581d850 into ruby:master Feb 2, 2025
81 checks passed
@nobu nobu deleted the shuffle-last-iter branch February 3, 2025 01:08
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

Successfully merging this pull request may close these issues.

2 participants