LoginSignup
0
0

More than 3 years have passed since last update.

渡されたパスにディレクトリが存在しない時に、空のディレクトリを新規作成するアロー関数/Lambda関数

Last updated at Posted at 2018-10-02

最近よく使うのでメモ。

アロー関数(Node.js)

const fs = require('fs')

const mkdirExceptExist = (dirPath) => {
    if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath); }
};

参考: https://www.gesource.jp/weblog/?p=7672

Lambda関数(Python)

import os

mkdirExceptExist = lambda path: "" if os.path.exists(path) else os.mkdir(path)

【Updated: 2019-07-21(Lambda関数を追加)】

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0