Skip to content

Allow block for Data#to_h - #3215

Merged
ksss merged 2 commits into
ruby:masterfrom
ksss:data-to-h-block
Oct 9, 2026
Merged

ksss merged 2 commits into
ruby:masterfrom
ksss:data-to-h-block

Conversation

@ksss

@ksss ksss commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Data#to_h accepts a block that returns key-value pairs, as documented:

distance.to_h { |name, val| [name.to_s, val.to_s] }
#=> {"amount"=>"10", "unit"=>"km"}

This adds the block overload, aligned with Struct#to_h, and a test for both forms.

🤖 Generated with Claude Code

ksss and others added 2 commits October 9, 2026 19:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ksss
ksss added this pull request to the merge queue Oct 9, 2026
Merged via the queue into ruby:master with commit e84e072 Oct 9, 2026
25 checks passed
@ksss
ksss deleted the data-to-h-block branch October 9, 2026 12:06
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