DEV Community

Discussion on: If Statement Golf: what's the longest one you've seen?

Collapse
 
grmnsort profile image
German Rodriguez Ortiz

I have this "little gem" to share :P

9 conditions and 203 characters long

if ( $hasNoDate || $hasNoDuration || $isPlannedWithoutProgress || $hasNoTask || $isConsolidated || $noTotalTaskWork || $notItemProgressIsOverLimit || $itemProgressIsOverLimit || $targetTaskIsMilestone)

It's used as a validation inside a foreach loop, each statement is a "challenge" that different attributes of the element currently in the loop have to pass, some are a simple bool cast of an atributte, others are longer comparisons or function returns.

It's original format was WAY LONGER :(

Collapse
 
jsn1nj4 profile image
Elliot Derhay

Still at least readable, and using only variables.

Collapse
 
bbasile profile image
Basile B.

Thanks God of Binary Operation for inventing bit sets. I think this expression would clearly be simplified by packet bits here.