Can someone explain/annotate this Ruby snippet with comments?
Posted
by Ronnie
on Stack Overflow
See other posts from Stack Overflow
or by Ronnie
Published on 2010-05-12T14:17:00Z
Indexed on
2010/05/12
14:24 UTC
Read the original article
Hit count: 294
Could someone please add comments to this code? Or, alternatively, what would be the pseudocode equivalent of this Ruby code?
It seems simple enough but I just don't know enough Ruby to convert this to PHP.
data = Hash.new({})
mysql_results.each { |r| data[r['year']][r['week']] = r['count'] }
(year_low..year_high).each do |year|
(1..52).each do |week|
puts "#{year} #{week} #{data[year][week]}"
end
end
Any help whatsoever would be really appreciated.
Thanks!
© Stack Overflow or respective owner