GPTScript / AiScript

A Minimal, Full-Stack, Tool-Assisted Language. Native to Browsers and Bun. Strictly & Strongly-Typed.
https://github.com/GPTScript/AiScript
Mozilla Public License 2.0
9 stars 1 forks source link

No ternary shorthand expressions #37

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

This rule comes from pretty much all decent languages (Go, Zig, Python).

❌ Bad

let a = b ? c : d ? : e;

✅ Good

// assign the fallback value
let a = e;
if (b) {
  if (c) {
    // update if the right conditions are met
    a = d;
  }
}

Rationalé

Ternaries are the devil's playground.

Readability counts.