Ruby 3 supports transforming hash keys using a hash argument
Transform hash keys with simple hash arguments in Ruby 3, eliminating verbose blocks.
This article was originally published on the BigBinary blog.
Ruby 3 added a neat quality-of-life improvement to transform_keys — you can now pass a hash argument to map old keys to new ones, instead of writing a block every time. It's a small change but it makes key renaming much more readable, especially when you're reshaping API responses or normalizing data. The article shows the before/after with concrete examples so you can see exactly when it's worth using.