0
Write in File using variable
I made a program, where you can choose a filename and the file gets created in another folder than the program. After that you can write a list( or what ever) and safe it in this file. There is my problem. I don't know how to do that. The problem is, that in the File.open statement the variable with the name doesn't work(looks like this): File.open(My_var, "w") {rest of the code...} Somebody knows what's my mistake?
1 Answer
+ 5
File.open works only for existing files, so if the file does not exist before runtime, you should use File.new, instead.
Also, check out the proper syntax:
https://www.sololearn.com/learn/Ruby/2742/