isEmpty
A value-based emptiness check: true for null, '', and empty collections.
Lecture
This is not the same thing as Iterable.isEmpty,
the getter you already get for free on every List, Set,
or Fx chain. That getter only exists on iterables, and blows
up (or is simply unavailable) on null. FxTS's isEmpty
takes any value and answers a broader question: is this thing
"nothing" in a practical sense? It returns true for
null, an empty String, and an empty
Iterable/Map/Set — and
false for everything else, including numbers and booleans,
which are never considered "empty."
Because it takes a single Object? argument, it tears off
directly into filter, reject, or any other
predicate-shaped slot without a wrapper lambda.
Demo 1 · Basics
Demo 2 · As a filter-friendly tear-off
A mixed bag of values, kept down to the ones isEmpty considers empty
(the printed empty string shows up as nothing between the commas):
Try it yourself
Exercise: use isEmpty to print 'no comment' when comment is empty, or the comment itself.
compact — drop nulls from an iterable ·
compactObject — drop nulls from a Map ·
predicates — more filter-friendly type checks ·
includes — the neighboring membership check