Project

General

Profile

Feature #6811

File, Dir and FileUtils should have bang-versions of singleton methods that fails silently

Added by prijutme4ty (Ilya Vorontsov) almost 8 years ago. Updated over 2 years ago.

Status:
Assigned
Priority:
Normal
Target version:
-
[ruby-core:46854]

Description

I found that often write
Dir.mkdir(folder) unless Dir.exist? folder
and similar code for rm, rm_rf and so on
We can simply make bang-versions like
def Dir.mkdir!(folder, permissions=0744)
Dir.mkdir(folder, permissions) unless Dir.exist? folder

or another alternative Dir.mkdir(folder, permissions) rescue false

end

Also available in: Atom PDF