-
Notifications
You must be signed in to change notification settings - Fork 215
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
core: Add Enumerator.produce #1516
Conversation
f3acb2a
to
2ee4404
Compare
@@ -124,6 +124,43 @@ | |||
class Enumerator[unchecked out Elem, out Return] < Object | |||
include Enumerable[Elem] | |||
|
|||
# <!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this document from enumerator.c. Is that alright?
https://github.com/ruby/ruby/blob/master/enumerator.c#L3052-L3086
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this comment by the result of CI (rake annotate
?): https://github.com/ruby/rbs/actions/runs/6149970207/job/16686945264?pr=1516
core/enumerator.rbs
Outdated
# PATTERN = %r{\d+|[-/+*]} | ||
# Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first | ||
# # => ["7", "+", "38", "/", "6"] | ||
def self.produce: (?untyped initial) { (untyped prev) -> untyped } -> self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first, I thought it would be better to use a type parameter for this method (ex. [T] (T initial) { (T prev) -> T } -> self[T, untyped]
).
But developers can use the different types between initial
and prev
(the return type of the block). So it's difficult to give a better type to this method to me. Therefore, I used untyped
for this.
638717a
to
d862f19
Compare
d862f19
to
6f8affc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @tk0miya and @ParadoxV5 ! 🎉
Add the signature for Enumerator.produce https://bugs.ruby-lang.org/issues/14781
Co-authored-by: Jimmy H <paradox.ver5@gmail.com>
ab4539a
to
3df06b7
Compare
Because the `#each` call never returns.
Add the signature for Enumerator.produce
https://bugs.ruby-lang.org/issues/14781