I’m trying to run this program (cToF.rb)
"
def convertCtoF (celsius)
print(celsius.to_s + " degrees celsius is " +
((celsius * 9) / 5 + 32).to_s + " degrees in
fahrenheit\n")
end
convertCtoF(ARGV[0])
"
in windows environment by typing
"
ruby cToF.rb 20
"
to the command file with the purpose of converting the given 20 to
fahrenheits; but ruby gives me an error message:
"
20cToF.rb:3:in convertCtoF': undefined method
/’ for
“202020202020202020”:String (NoMethodError)
from cToF.rb:8:in `’
".
ARGV[0] should yield 20 and the program works if I just replace the
ARGV[0] with 20 in the program code so I don’t get why the program wont
work with this code! The problem is probably something very simple -
could you let me know what I’m doing wrong here?? Many thanks!