Ruby newbie: undefined method `with_indifferent_access'

后端 未结 2 712
长情又很酷
长情又很酷 2021-02-19 18:39

I am a new Ruby programmer, and a co-worker of mine to help me get started wrote the following code which ran fine in his environment. However, when I try to run it in my own e

2条回答
  •  逝去的感伤
    2021-02-19 19:13

    By the way, HashWithIndifferentAccess is really powerful as long as you use it with caution.

    For example:

    h = HashWithIndifferentAccess.new()
    some_array.each do |a|
      h["#{a}"] = "anything you want"
    end
    

    I use it all the time when working with slices of data in metrics.

提交回复
热议问题