Skip to content

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

class method

File.split

File.split(file_name) → array

Splits the given string into a directory and a file component and returns them in a two-element array. See also File::dirname and File::basename.

Example
File.split("/home/gumby/.profile")   #=> ["/home/gumby", ".profile"]
See also .socket? .stat .size? .sticky? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0