google/closure-compiler

Compress condition as logical expression

开放

#1,842 创建于 2016年6月13日

 (3 条评论) (0 个反应) (0 位负责人)Java (1,197 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (7,176 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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!

贡献者指南