Introduction
Sometimes, lists have empty spots called nil in Ruby. compact helps clean the list by removing these empty spots.
When you have a list of items and want to ignore empty or missing values.
When you get data from a form or user input that might have blanks.
When you want to prepare a list for counting or showing only real items.