Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

FileTest#file?

File.file?(file) → true or false

Returns true if the named file exists and is a regular file.

file can be an IO object.

If the file argument is a symbolic link, it will resolve the symbolic link and use the file referenced by the link.

See also #exist? #grpowned? #executable_real? #identical? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1