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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Enumerable#to_h(&block) #7150

Merged
merged 3 commits into from Dec 7, 2018

Conversation

Projects
None yet
4 participants
@Sija
Copy link
Contributor

Sija commented Dec 5, 2018

Re: 馃巹 shopping spree at Ruby 2.6 land ;)

@asterite
Copy link
Contributor

asterite left a comment

This is inefficient. You should create a Hash, call each and assume it's a tuple and add that to the hash.

@Sija Sija force-pushed the Sija:feature/to_h-with-block branch from 9863fca to c8a14db Dec 5, 2018

@Sija

This comment has been minimized.

Copy link
Contributor Author

Sija commented Dec 5, 2018

@asterite spot on, fixed.

@asterite
Copy link
Contributor

asterite left a comment

I think instead of U you can use Tuple(X, Y) forall X, Y and use those types to initialize the Hash.

@Sija

This comment has been minimized.

Copy link
Contributor Author

Sija commented Dec 5, 2018

I was thinking of that but then it would have to be Array(X | Y) | Tuple(X, Y).

@asterite

This comment has been minimized.

Copy link
Contributor

asterite commented Dec 5, 2018

Why Array? Tuple is enough. If you have an Array as the block value the caller can always convert that to a duple. Enforcing tuple guarantees a minimum level of performance.

@Sija

This comment has been minimized.

Copy link
Contributor Author

Sija commented Dec 5, 2018

Fair 'nuff, pushed an update.

Show resolved Hide resolved src/enumerable.cr Outdated
Show resolved Hide resolved src/enumerable.cr Outdated
@RX14

RX14 approved these changes Dec 7, 2018

@RX14 RX14 added this to the 0.27.1 milestone Dec 7, 2018

@RX14 RX14 merged commit 24f545a into crystal-lang:master Dec 7, 2018

3 of 4 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
ci/circleci: test_darwin Your tests passed on CircleCI!
Details
ci/circleci: test_linux Your tests passed on CircleCI!
Details
ci/circleci: test_linux32 Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment