DEV: Fix rubocop issues (PR #14715)

GitHub

I’m curious, what’s the difference between IO.readlines and File.readlines?

I don’t think there is one. File doesn’t implement .readlines, it inherits the method from IO.

1 Like

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! :tired_face: Thanks for the link!