Better way to do this?

Alex Treber wrote:

Luke wrote:   

total = 0 1.upto(7) { |i| total += row.send("day#{i}") }      Ah, I like that a lot better. So send is the way to go.

Does the #{i} format work with arrays as well? value[:d1] - value[:d7] could be value[:d#{i}]?

The #{i} format works in double quoted strings and does not work with symbols. If the keys for value were 'd1', 'd2', etc. (strings) instead of :d1, :d2 (symbols), then you could use value["d#{i}]

Hi --