Logo

Programming-Idioms

  • Kotlin
  • C++

Idiom #273 Check if folder is empty

Set the boolean b to true if the directory at filepath p is empty (i.e. doesn't contain any other files and directories)

import os
b = os.listdir(p) == []
import 'dart:io';
var b = await Directory(p).list().isEmpty;

New implementation...
< >
programming-idioms.org