protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Ruby: allow Google::Protobuf::Map#to_h to accept a block

Open bhang-stripe opened this issue 1 week ago • 3 comments

In Ruby, Google::Protobuf::Map is an Enumerable. From the Ruby documentation for Enumerable#to_h:

If a block is given, the results of the block on each element of the enum will be used as pairs.

This PR adds the ability to pass in a block and have the described behavior.

This is useful, otherwise we'd need to do something like call map and then to_h, which allocates intermediate results.

bhang-stripe avatar Jan 07 '26 17:01 bhang-stripe

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Jan 07 '26 17:01 google-cla[bot]

Before we can review this PR, please sign the CLA.

JasonLunn avatar Jan 07 '26 20:01 JasonLunn

Before we can review this PR, please sign the CLA.

Done!

bhang-stripe avatar Jan 07 '26 20:01 bhang-stripe