Emptiness
Great thinking over at Khanlou.com about types that implement isEmpty
and the weird tri-state they can be in if Optional
. I also have a self-imposed rule forbidding optional Array
s and Dictionary
s.
I should probably extend this practice to String
s, but treating ""
different from " "
gives me the heeby jeebies. So I have a maybeBlank()->String?
extension on String
that returns the string or nil
if it’s empty or whitespace.
This article really calls out how insane that is.