On Wed, Dec 26, 2012 at 10:59 PM, 7stud -- <[email protected]> wrote:
> Robert Klemme wrote in post #1090246:
>>
>>
>> Why isn't that simple? Did you actually try it?
>>
>> require 'date'
>>
>> counts = Hash.new 0
>>
>> ARGF.each do |line|
>> line.chomp!
>> counts[Date.parse(line)] += 1
>> end
>>
>> counts.sort_by {|d,| k}.each do |d, c|
>> printf "%-20s %6d\n", d, c
>> end
>>
>> Cheers
>>
>> robert
>>
>
> 1.rb:10:in `block in <main>': undefined local variable or method `k' for
> main:Object (NameError)
Typo when ad hoc refactoring names
require 'date'
counts = Hash.new 0
ARGF.each do |line|
line.chomp!
counts[Date.parse(line)] += 1
end
counts.sort_by {|d,| d}.each do |d, c|
printf "%-20s %6d\n", d, c
end
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en