google/closure-compiler

Compress condition as logical expression

Open

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

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Java (1,197 fork)batch import
enhancementhelp wanted

仓库指标

Star
 (7,176 star)
PR 合并指标
 (平均合并 3天 4小时) (30 天内合并 1 个 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!

贡献者指南