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) over 11 years ago. Updated over 6 years ago.

Status:
Assigned
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

Like0
Like0Like0Like0Like0Like0Like0Like0