Reputation: 495
I'm going through "Learn Ruby the Hard Way" and I can't get my Windows command prompt to display the docs for: ri File.open
It just gives me an error:
ArgumentError: wrong number of arguments (0 for 1..3)
I'm currently on exercise 16: http://ruby.learncodethehardway.org/book/ex16.html
And the extra credit says: If you open the file with 'w' mode, then do you really need the target.truncate()? Go read the docs for Ruby's File.open function and see if that's true.
where can I see the docs for the File.open function?
Upvotes: 3
Views: 3605
Reputation: 17020
Read the documentation of IO
, File
's parent class. It describes the file opening modes you mentioned in your question. Here's the description for the w
opening mode:
"w" Write-only, truncates existing file
to zero length or creates a new file for writing.
So no, you don't really need to call target.truncate
if you open the file in w
mode.
Upvotes: 5