Logo

Programming-Idioms

  • Ada
  • Go
  • Rust

Idiom #320 Test if string is empty

Set b to true if the string s is empty, false otherwise

b = s.is_empty()

Both &str and String have a method called is_empty
b := s == ""

Strings cannot be nil
#include <string.h>
bool b = !strlen(s);

C23 bool

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