combining all the things (arrow with implicit return + arguments default + ternary)
```js const newFoo = ((x = getSomething()) => x ? (doSomethingFirst(), x.doSomething()) : doSomethingElse() )(); ``` So yeah, we probably don't need yet another pattern/new syntax to do that. Regards On Wed, Sep 20, 2017 at 2:04 PM, T.J. Crowder < [email protected]> wrote: > On Wed, Sep 20, 2017 at 12:52 PM, Bob Myers <[email protected]> wrote: > > > > Could you please clarify how the system would know that some > > random expression in the middle of something like this for/if > > construct should be treated as a sort of "return"? > > Sorry, my example was missing a `break`. And it may have been off, since > the `break` (rather than `x.foo`) would be the last executed statement. The > main point was: You can use statements in `do` expressions, not with the > comma operator. > > > By the way, in current iterations of the `do` concept is there > > a `return`? > > As far as I could tell reviewing the discussion hat the TC39 proposals > list refers to, it hasn't been decided. As someone points out in the > comments, with `return` it's effectively an IIFE. Folks seem quite > interested in `do` expressions but I'm having trouble seeing much need for > them in a world with IIFEs and arrow functions: > > ```js > const x = (() => { > for (const x of getTheThings()) { > if (x.id == something) { > return x.foo; > } > } > })(); > ``` > > I mean, yes, even with `return` the `do` expression version of that would > be *slightly* more concise, but... > > We're off-topic, though. This is about `do` expressions. The thread is > about "result-forwarding ternary operators". > > -- T.J. Crowder > > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

