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

De-sum 2 #35

Merged
merged 1 commit into from
Apr 6, 2018
Merged

De-sum 2 #35

merged 1 commit into from
Apr 6, 2018

Conversation

cheerfulstoic
Copy link
Contributor

No description provided.

Copy link

@jones-agyemang jones-agyemang left a comment

Choose a reason for hiding this comment

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

👍

@@ -2,7 +2,7 @@ class Array
def entropy
each_with_object(Hash.new(0)) do |i, result|
result[i] += 1
end.values.sum do |count|
end.values.inject(0, :+) do |count|

Choose a reason for hiding this comment

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

sum is clearer than inject(0, :+). However, sum without a block will not work. This is a valid fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was because sum didn't exist outside of Rails / activesupport, but in my environment I had those and so I didn't notice this.

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

Fair enough :)

Copy link
Owner

@igrigorik igrigorik left a comment

Choose a reason for hiding this comment

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

👍

@igrigorik igrigorik merged commit 2486d0d into igrigorik:master Apr 6, 2018
@cheerfulstoic cheerfulstoic deleted the patch-3 branch April 6, 2018 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants