or a simple utility method

On Thu, Oct 9, 2014 at 6:35 AM, Andrea Giammarchi <
andrea.giammar...@gmail.com> wrote:

> probably not exactly the fat arrow usage you were looking for ... but it
> makes it trivial to inline any sort of block
>
> ```js
> asyncFunc()
> .then(count => count >= 0 ? count : ()=>{throw new Error(...)}())
> .then(...)
> .catch(...);
> ```
>
> Regards
>
>
> On Thu, Oct 9, 2014 at 1:23 PM, Axel Rauschmayer <a...@rauschma.de> wrote:
>
>> Use case: With promises, the expression body form of arrow functions is
>> so convenient. Alas, `throw` being a statement, you can’t use it there. For
>> example, the following code is not syntactically legal:
>>
>> ```js
>> asyncFunc()
>> .then(count => count >= 0 ? count : throw new Error(...))
>> .then(...)
>> .catch(...);
>> ```
>>
>> Could `throw` be turned into an expression?
>>
>> --
>> Dr. Axel Rauschmayer
>> a...@rauschma.de
>> rauschma.de
>>
>>
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to