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"? I can understand that the **last**
expression in a block would be the return value, but how would it know that
`x.foo` was an implicit return? By the way, in current iterations of the
`do` concept is there a `return`?
```js
const x = do {
    for (const x of getTheThings()) {
        if (x.id == something) {
            x.foo;
        }
    }
};
```

On Wed, Sep 20, 2017 at 4:11 PM, T.J. Crowder <
[email protected]> wrote:

> On Wed, Sep 20, 2017 at 11:28 AM, Naveen Chawla <[email protected]>
> wrote:
> >
> > The comma operator seems to make the `do` concept redundant, at
> > least for me.
>
> No, not at all. Again: With the comma operator, you can't use
> *statements*, only expressions. With the `do` expression, you can use
> actual statements:
>
> ```js
> const x = do {
>     for (const x of getTheThings()) {
>         if (x.id == something) {
>             x.foo;
>         }
>     }
> };
> ```
>
> ...which is basically:
>
> ```js
> const x = getTheThings().find(x => x.id == something).foo;
> ```
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to