Help us understand the problem. What is going on with this article?

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

最近よく使うのでメモ。

アロー関数(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関数を追加)】

Hirosaji
ゲーム実況を観ながらプログラミングをするのが好きなWebエンジニアです。
https://bl.ocks.org/hirosaji
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away