Skip to content

Add Regexp.try_convert and IO.try_convert - #475

Merged
tannevaled merged 1 commit into
mainfrom
feat/cluster45
Aug 28, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/cluster45

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The try_convert class method existed for Array/Hash/String/Integer;
this extends it to Regexp (via #to_regexp) and IO (via #to_io). An
argument already of the class is returned by identity, one responding to the
conversion method is converted (a nil result passes through, a wrong-typed
result raises TypeError), and anything else returns nil — reusing the shared
tryConvert protocol.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
ratchet floor rises 15870 → 15880 (core/regexp/try_convert +4,
core/io/try_convert +6, zero regressions in a deterministic per-file sweep).

🤖 Generated with Claude Code

The try_convert class method existed for Array/Hash/String/Integer; extend it to
Regexp (via #to_regexp) and IO (via #to_io). An argument already of the class is
returned by identity, one responding to the conversion method is converted (a nil
result passes through, a wrong-typed result raises TypeError), and anything else
returns nil — reusing the shared tryConvert protocol.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
floor rises 15870 -> 15880 (core/regexp/try_convert +4, core/io/try_convert +6).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit fb52b88 into main Aug 28, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster45 branch August 28, 2026 12:07
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.

1 participant