On Mon, Dec 3, 2012 at 4:28 PM, Andrea Giammarchi <
andrea.giammar...@gmail.com> wrote:

> I wonder what was the use case that convinced TC39 to return `this` with
> these methods.


Assuming you read the notes, I proposed the agenda item based on the best
practice of ensuring meaningful returns, and in the case of mutation
methods, |this| is a meaningful return.


> Accordingly, this will never work:
> var query = map.has('queried') ? map.get('queried') :
> map.set('queried', $('myquery'));
>

Previously, map.set() had a useless void return...


>
> And it will be something like:
> var query = map.has('queried') ? map.get('queried') :
> map.set('queried', $('myquery')).get('queried');
>
> which is ugly and I don't really understand where map.set(k0, v0).set(k1,
> v1).set(k2, v2) could be useful.
>

Accessing the object post-mutation allows for more expressive use of the
API.


Rick


> Thanks for clarifications ( a use case would be already good )
>
> br
>
> _______________________________________________
> 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