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

Handle non array return values in Enumerable#flat_map #3427

Merged
merged 2 commits into from
Oct 18, 2016
Merged

Handle non array return values in Enumerable#flat_map #3427

merged 2 commits into from
Oct 18, 2016

Conversation

timcraft
Copy link
Contributor

Fix for #3415. This is closer to the Ruby behaviour, which preserves elements not in arrays (including Enumerable objects). For example:

[[1, 2, 3], 4, {5 => 6}].flat_map { |x| x }
# => [1, 2, 3, 4, {5=>6}]

@luislavena
Copy link
Contributor

Hello @timcraft, perhaps you can add a spec that actually confirms the pull description? The example 3 only does flattening, but there is no example of a Hash inside the Array.

Thank you.

@timcraft
Copy link
Contributor Author

@luislavena Sure. I've added another example of an array containing hashes in ead6c60

The pull description is Ruby code (to demonstrate Ruby's behaviour).

@asterite
Copy link
Member

@timcraft Thank you for this!

@asterite asterite merged commit 8d326cc into crystal-lang:master Oct 18, 2016
@asterite asterite mentioned this pull request Oct 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants