Skip to content

Conversation

eksperimental
Copy link
Contributor

No description provided.

new(first + steps_to_shift * step, last + steps_to_shift * step, step)
def shift(range, steps_to_shift)

def shift(range, 0) when is_struct(range, Range), do: range
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def shift(range, 0) when is_struct(range, Range), do: range
def shift(%Range{} = range, 0), do: range

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@josevalim I wanted to ask you if there's any performance difference doing pattern matches vs is_struct/2? Or it is just a matter of style.
Personally I favor the is_struct/2 approach as it declutter the function arguments section a bit.

@josevalim josevalim merged commit 9f8bacd into elixir-lang:main Aug 28, 2025
13 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

ggVGc pushed a commit to ggVGc/elixir-verbatim that referenced this pull request Sep 12, 2025
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