From: "Thibaut Barrère" Date: 2006-03-13T23:33:46+09:00 Subject: Recursive line counter (review?) Hi I'm practicing ruby everyday on small tools to learn more, could anyone review what I've coded today ? This is a basic line of code counter (pure ruby), any feedback welcome! thanks ! Thibaut def loc_file(file) File.open(file).inject(0) { |loc,line| loc+1 } end def loc_by_extension(root,ext) Dir[root+ext].inject(0) { |total,f| total + loc_file(f) } end ["*.cs","*.cpp","*.h","*.resx"].each do |ext| puts "#{loc_by_extension('c:/evolutionsyncfusion/**/',ext)} loc for #{ext}" end