How to make dynamic multi-dimensional array in ruby?
问题 I have a beginner ruby question about multi dimensional arrays. I want to sort entries by year and month. So I want to create a multi-dimensional array that would contain years -> months -> entries of month So the array would be like: 2009 -> 08 -> Entry 1 -> Entry 2 09 -> Entry 3 2007 -> 10 -> Entry 5 Now I have: @years = [] @entries.each do |entry| timeobj = Time.parse(entry.created_at.to_s) year = timeobj.strftime("%Y").to_i month = timeobj.strftime("%m").to_i tmparr = [] tmparr << {month=