From: "rosenfeld (Rodrigo Rosenfeld Rosas)" Date: 2013-06-07T22:29:29+09:00 Subject: [ruby-core:55357] [ruby-trunk - Feature #8490] Bring ActiveSupport Enumerable#index_by to core Issue #8490 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas). I can't show you my code, but here are some common usage you can find on Github open source code: https://github.com/dim/plexigrid/blob/6358f11af7806849de756c226791c53f39521efc/rails_plugin/plexigrid/lib/plexi_grid/column_model.rb#L21 https://github.com/astrails/benyehuda-cases-server/blob/e3b797d2edf005f4a338179bd2b1ed8aa2935597/lib/custom_properties.rb#L16 https://github.com/zerglings/upside_web/blob/b2326f23673f300b47572665de8a7f7a67b4c992/app/models/stock_cache_line.rb#L58 Notice in this last example that the cache_fetch method would also benefit from index_by. It is the same as lines_for but it takes an expiration time argument. ---------------------------------------- Feature #8490: Bring ActiveSupport Enumerable#index_by to core https://bugs.ruby-lang.org/issues/8490#change-39773 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Rejected Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: It seems to be a common sense to have the useful implementation of Enumerable#index_by as in ActiveSupport. index_by acts like group_by but only maps a single record, instead of an array, keeping the last match only. It's usually used in places where you shouldn't have more than a single match for each key. Would you consider its inclusion to core Enumerable module? -- http://bugs.ruby-lang.org/