Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

tweaking multi-line ternary #3

Open
wants to merge 1 commit into from

2 participants

@jmonster
  • I’m making this change to pass JSHint.
  • doing it this way means that none of the lines are valid expressions by themselves. Keeping the ? on the first line disables that line from existing in isolation.
@jmonster jmonster tweaking multi-line ternary
I’m making this change to pass JSHint. Additionally, doing it this way
means that none of the lines are valid expressions by themselves.
Keeping the `?` on the first line disables that line from existing in
isolation.
df1b47b
@lxe lxe commented on the diff
README.md
@@ -238,9 +238,9 @@ The ternary operator should not be used on a single line. Split it up into multi
*Right:*
```js
-var foo = (a === b)
- ? 1
- : 2;
+var foo = (a === b) ?
+ 1 :
+ 2;
@lxe
lxe added a note

ugh this is now worse.

it now serves a runtime unambiguity purpose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lxe

:-1:

My opinion:

// GOOD
var foo = (a === b) ? 1 : 2;

// UNNECESSARY
var foo = (a === b) 
  ? 1 
  : 2;

// BAD 
var fluxCapacitorBatteryHorseStaple = somethingRatherMattLiegey === false ? someResult : otherResult;

// GOOD
var fluxCapacitorBatteryHorseStaple = somethingRatherMattLiegey === false 
  ? someResult 
  : otherResult;

// ALSO GOOD
var fluxCapacitorBatteryHorseStaple 
  = somethingRatherMattLiegey === false 
    ? someResult 
    : otherResult;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 21, 2014
  1. @jmonster

    tweaking multi-line ternary

    jmonster authored
    I’m making this change to pass JSHint. Additionally, doing it this way
    means that none of the lines are valid expressions by themselves.
    Keeping the `?` on the first line disables that line from existing in
    isolation.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 README.md
View
6 README.md
@@ -238,9 +238,9 @@ The ternary operator should not be used on a single line. Split it up into multi
*Right:*
```js
-var foo = (a === b)
- ? 1
- : 2;
+var foo = (a === b) ?
+ 1 :
+ 2;
@lxe
lxe added a note

ugh this is now worse.

it now serves a runtime unambiguity purpose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
```
*Wrong:*
Something went wrong with that request. Please try again.