Hacker News new | ask | show | jobs
by jhawthorn 5441 days ago
Other than recommending #map, #select, et al, the rest is poor advice. Consider the following recommendation

  input.inject({}) do |hash, item|
    hash.merge(item => process(item))
  end
Far, far slower, more memory intensive (big deal, given ruby's gc), and uglyer than the sane (and commonly accepted)

  Hash[input.map do |item|
    [item, process(item)]
  end]