I have a method opening and appending to a file as so:
def writeFile(ofile,number)
File.open(ofile, 'a') { |file| file.puts(number) }
end
Which is called after line processing by another method.
def method(ofile, ifile, number)
File.foreach("#{ifile}") do |line|
if number > 3
writeFile(ofile, number)
end
end
My question is, should I just get rid of the writeFile method? It seems wrong to me. It keeps opening the file to write to it, when I should only open it once then write when needed.
method_namerather thanmethodName. – Nat Feb 16 at 15:17methodis an existing method defined on Object, and you are trampling it. – steenslag Feb 26 at 22:15