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

Correct oversights in Enum.slide/3 #11361

Merged
merged 1 commit into from
Nov 3, 2021
Merged

Conversation

s3cur3
Copy link
Contributor

@s3cur3 s3cur3 commented Nov 3, 2021

This fixes two issues I've discovered in v1.13-rc.0 (stuff that should have been in #11349 😬).

  • Adds support for negative insertion indices:

      iex> Enum.slide([:a, :b, :c, :d, :e, :f], 1..2, -2)
      [:a, :d, :e, :b, :c, :f]
      iex> Enum.slide([:a, :b, :c, :d, :e, :f], -5..-3//1, -2)
      [:a, :e, :b, :c, :d, :f]
    
  • Give a clear RuntimeError, rather than a baffling CondClauseError, when you ask for an insertion point that matches the last element of your range

      iex> XUtil.Enum.slide([:a, :b, :c, :d, :e, :f], 1..2, 2) 
      ** (RuntimeError) Insertion index for slide must be outside the range being moved (tried to insert 1..2 at 2)
    

- Support negative insertion indices
- Give a clear RuntimeError, rather than a baffling CondClauseError, when you ask for an insertion point that matches the last element of your range
@s3cur3 s3cur3 marked this pull request as ready for review November 3, 2021 17:20
@josevalim josevalim merged commit 1766731 into elixir-lang:v1.13 Nov 3, 2021
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

josevalim pushed a commit that referenced this pull request Nov 3, 2021
- Support negative insertion indices
- Give a clear RuntimeError, rather than a baffling CondClauseError, when you ask for an insertion point that matches the last element of your range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants