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 doc Set#each returns nil instead of self #10477

Merged
merged 1 commit into from
Mar 9, 2021
Merged

Fix doc Set#each returns nil instead of self #10477

merged 1 commit into from
Mar 9, 2021

Conversation

kachick
Copy link
Contributor

@kachick kachick commented Mar 6, 2021

I think current spec is correct.

set.each do |v|
v.should eq(i)
i += 1
end.should be_nil

My understanding is below. If it is not correct, I'll fix the implementation and spec instead of documentation changes.

Returning self on `#each` method is a Ruby conventional interface.
Crystal style is returning nil on `#each` method.

crystal/src/hash.cr

Lines 1259 to 1263 in 9d7e162

def each : Nil
each_entry_with_index do |entry, i|
yield({entry.key, entry.value})
end
end

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:docs topic:stdlib:collection labels Mar 6, 2021
@kachick kachick changed the title Fix doc Set#each returs nil instead of self Fix doc Set#each returns nil instead of self Mar 7, 2021
Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

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

Thank you @kachick 🙏

@bcardiff bcardiff added this to the 1.0.0 milestone Mar 9, 2021
@bcardiff bcardiff merged commit b02581f into crystal-lang:master Mar 9, 2021
@bcardiff
Copy link
Member

bcardiff commented Mar 9, 2021

Leftover since #3826 😅

@kachick
Copy link
Contributor Author

kachick commented Mar 10, 2021

Thank you all!

@bcardiff Thank you for letting me know 🙏

@kachick kachick deleted the fix-set-each-returned-value branch March 10, 2021 03:31
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. kind:docs topic:stdlib:collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants