I am using Ruby and Ruby on Rails 3 and I would like to know...
... what is the difference between
File.read("filename.txt")
and
IO.read("filename.txt")
?
n. A file containing materials ordered by date or other time sequence that is circulated for reading or reference.
File Opening Modes'r' – Read Mode: This is the default mode for open(). The file is opened and a pointer is positioned at the beginning of the file's content. 'w' – Write Mode: Using this mode will overwrite any existing content in a file. If the given file does not exist, a new one will be created.
since File is a subclass of IO and it does not have the read method, when you invoke File.read, you are actually calling IO.read no difference here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With