Hi,
I’m trying to write to a new file, wich I’m creating by
file=File.new(‘file.txt’, ‘w’)
This works fine so far, the file is created in my working folder and
contains the text I’m putting in.
Now I want the user to input the filename, so I modified my source code
like this:
print "Please insert file name: "
file_name=gets
file=File.new(file_name+’.txt’, ‘w’)
Running the Programm and inputting ‘test’ (without the ‘’), I get the
following Error:
…\rubyfile.rb:116:in initialize': Invalid argument - test (Errno::EINVAL) .txt from ..\rubyfile.rb:116:in
new’
from …\rubyfile.rb:116
I have no idea, what’s going wrong… Since file_name is a string,
file_name+’.txt’ ought to be a string too, and thus a valid argument for
the initializer method of File, or not?
Sorry, if my question is dumb, I’m a total noob with ruby…
Thanks for any help!
taura