Project

General

Profile

Actions

Feature #6811

open

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

Added by prijutme4ty (Ilya Vorontsov) about 9 years ago. Updated over 3 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

Actions

Also available in: Atom PDF