Last Updated: June 6, 2026
Optional<T> is a container that either holds a value or holds nothing, and it advertises that fact in the method's return type. It exists so a caller can't forget that a lookup might come back empty. This lesson covers when to use Optional, how to construct and read it, the functional methods that make it pleasant to work with, the cost traps to avoid, and the places it doesn't belong.