Skip to content

Correct oversights in Enum.slide/3#11361

Merged
josevalim merged 1 commit into
elixir-lang:v1.13from
s3cur3:v1.13
Nov 3, 2021
Merged

Correct oversights in Enum.slide/3#11361
josevalim merged 1 commit into
elixir-lang:v1.13from
s3cur3:v1.13

Conversation

@s3cur3

@s3cur3 s3cur3 commented Nov 3, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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