Introduction
CompactMap helps you clean up a list by removing empty or missing values. It unwraps optionals safely and keeps only real values.
You have a list with some missing or empty values and want only the real ones.
You want to convert a list of strings to numbers, ignoring the ones that can't be converted.
You want to filter out nil values from a list of optional items.
You want to clean user input data by removing blanks or invalid entries.