+ 2
File.open or File.new?
What is the different between these methods?
2 Answers
+ 13
You cannot open an existing file with File.new. File.open is used to open an existing file, and is a synonym for ::new when the specified file is found to be associated with no block.
https://ruby-doc.org/core-2.1.4/File.html
+ 1
Thanks, I tried it in the sandbox and new didn't work. Even if the file doesn't exist.