Type: Function
โ
โFunction: IF_ZERO
Syntax: IF_ZERO(value, fallback_if_zero)
Description: Returns the first value or the second value (fallback) if the first one is equal to 0
. The value and its fallback must have the same type.
Sample usage:
IF_ZERO(lines_changed, 1)
returns1
instead oflines_changed
if the latter is equal to zero. This operator is particularly useful when doing divisions.SUM(deletions)/SUM(IF_ZERO(additions, 1))*100
returns a refactoring ratio (percentage) and handles the case where no lines were added (additions = 0
).