Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

ksss
Copy link
Collaborator

@ksss ksss commented Jun 21, 2024

Argument of Enumerator#initialize allows nil, #call and #to_int object.
Included Float::INFINITY in #to_int.

https://github.com/ruby/ruby/blob/ac9e84df3d0b06e62498aafbca99e8f8475ec142/enumerator.c#L437-L451

@ksss ksss changed the title [Enumerator#initialize] support nil, #call and #to_int Enumerator#initialize support nil, #call and #to_int Jun 21, 2024
# object.
#
def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> Return } -> void
def initialize: (?(nil | _Call | ::_ToInt) arg0) { (Enumerator::Yielder arg0) -> Return } -> void
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def initialize: (?(nil | _Call | ::_ToInt) arg0) { (Enumerator::Yielder arg0) -> Return } -> void
def initialize: (?(int? | _Call) size) { (Yielder yielder) -> Return } -> void

Comment on lines +272 to +274
interface _Call
def call: () -> untyped
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Enumerator.new(->{'hi'}) {}.size #=> "hi"
Suggested change
interface _Call
def call: () -> untyped
end
interface _Size
def call: () -> (Integer | Float)?
end

Relevant: #420 (comment)

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.