Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Pathname#rmdir

() -> 0
rmdir → 0

Deletes the directory at the path in self; returns 0:

Example
pn = Pathname('doc/foo')
pn.mkdir
pn.rmdir

Raises an exception if the entry at the path in self is not a directory, or if the directory is not empty.

Use method rmtree to delete the entire filetree at the path.

See also #rename #rmtree #relative_path_from #root? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0