Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between 'File.read' and 'IO.read'?

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") 

?

like image 611
user502052 Avatar asked Feb 27 '11 15:02

user502052


People also ask

What does read file mean?

n. A file containing materials ordered by date or other time sequence that is circulated for reading or reference.

What is the difference between reading and writing a file in Python?

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.


1 Answers

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.

like image 158
ALoR Avatar answered Oct 13 '22 07:10

ALoR