Ruby: output not saved to file
Posted
by
Sophie
on Stack Overflow
See other posts from Stack Overflow
or by Sophie
Published on 2011-03-20T18:47:01Z
Indexed on
2011/03/20
19:21 UTC
Read the original article
Hit count: 288
I'm trying to give a file as input, have it changed within the program, and save the result to a file that is output. But the output file is the same as the input file. :/ Total n00b question, but what am I doing wrong?:
puts "Reading Celsius temperature value from data file..."
num = File.read("temperature.dat")
celsius = num.to_i
farenheit = (celsius * 9/5) + 32
puts "Saving result to output file 'faren_temp.out'"
fh = File.new("faren_temp.out", "w")
fh.puts farenheit
fh.close
© Stack Overflow or respective owner