As Ruby 2.6 added support for executing a block when passed to to_h I think we can add it with the other implementations to achieve the same output.
Ruby on Rails also has a shorter way Enumerable#index_by which I didn't want to include, but it's worth mentioning for those working with the framework.
As Ruby 2.6 added support for executing a block when passed to
to_h
I think we can add it with the other implementations to achieve the same output.Ruby on Rails also has a shorter way
Enumerable#index_by
which I didn't want to include, but it's worth mentioning for those working with the framework.