Do you use null condition operators when getting values from objects
29/01/2020 4:35 PM by
Null-conditional operators - makes checking for null as easy as inserting a single question mark. The Null-conditional operators feature boils down all of the previously laborious clunky code into a single question mark.
int length = customer != null && customer.name != null ? customer.name.length : 0; Figure: Bad Example - Verbose and complex code checking for nulls
int length = customers?.name?.length ?? 0;Figure: Good Example - Robust and easier to read code
Do you feel this rule needs an update?