google/closure-compiler

Compress condition as logical expression

Open

#1842 aperta il 13 giu 2016

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Java (1197 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (7176 star)
Metriche merge PR
 (Merge medio 3g 4h) (1 PR mergiata in 30 g)

Descrizione

Hi,

I wonder if it's possible to shrink an expression like

if (!a)
   c = b;
else
   c =a;

to

c = a || b;

instead of

c = a ? a : b;

You do such tricks already in a logical manner to kick out if-statements, but it would make sense within expressions as well. Or do I miss something, that it should be avoided?

Thanks!

Guida contributor