I’m curious, what’s the difference between
I don’t think there is one.
File doesn’t implement
.readlines, it inherits the method from
File.readlines checks if the argument is a valid filename.
IO does not.
What does “valid filename” mean? Just that the string look like a path to a filename or that a file actually exists at this path?
Oh, I meant that a file exists.
Is this documented anywhere? I don’t see that in Class: File (Ruby 2.5.2) / ruby/file.c at a4d5ee4f31bf3ff36c1a8c8fe3cda16aa1016b12 · ruby/ruby · GitHub
Here is the code you are interested in:
IO.open acts differently depending on the current class. I find it a bit hacky, but that’s how they do it.
Uhh, hacky and undocumented! Thanks for the link!