google/closure-compiler

Compress condition as logical expression

Open

#1,842 opened on Jun 13, 2016

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Java (1,197 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (7,176 stars)
PR merge metrics
 (Avg merge 3d 4h) (1 merged PR in 30d)

Description

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!

Contributor guide