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

Fix Enumerable#zip to work with union types #8621

Merged
merged 1 commit into from
Dec 25, 2019
Merged

Fix Enumerable#zip to work with union types #8621

merged 1 commit into from
Dec 25, 2019

Conversation

asterite
Copy link
Member

Fixes #8608

Using runtime is_a? instead of compile-time checks makes it work for union types.

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:collection labels Dec 25, 2019
# Try to see if we need to create iterators (or treat as iterators)
# for every element in `others`.
{% for type, type_index in U %}
{% if type < Indexable %}
if other{{type_index}}.is_a?(Indexable)
Copy link
Contributor

@Sija Sija Dec 25, 2019

Choose a reason for hiding this comment

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

case would be imo tad moar cleaner here:

case other{{type_index}}
when Indexable
  # ...
when Iterable
  # ...
end

ditto below in .zip?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed. And also did it a bit differently...

@asterite asterite merged commit c8020f0 into master Dec 25, 2019
@asterite asterite added this to the 0.33.0 milestone Dec 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indexable itself cannot be used for Enumerable#zip
3 participants