Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates
Kernel#Integer
to be more correct.Notably, in the one-argument form, the first argument needs to either define
to_int
,to_i
, orto_str
to be convertible. Additionally, int he two-argument form, the first argument just needs to defineto_str
, and the secondto_int
.Like the other conversion
fuctions,
ifexception: false
is explicitly given, the return value is anInteger?
. Additionally,(untyped, ?untyped, exception: false) -> nil
was added, as any types are accepted whenexception: false
is supplied.One thing to note, however, is that this definition isn't technically complete: The one-argument form can technically take a second argument. However, this argument needs to either:
to_int
, which when called returns0
, orto_int
!(For example,
Integer 123, :a
is valid.) Neither of these things is really possible to do in RBS, and attempting to force it in wouldn't work well, so I've leftit out.