(Map|Set|WeakMap)#set() returns `this` ?
brendan at mozilla.org
Fri Dec 7 20:50:35 PST 2012
Andreas Rossberg wrote:
> On 6 December 2012 18:38, Rick Waldron<waldron.rick at gmail.com> wrote:
>>> I agree with other voices in this thread that in general, returning
>>> 'this' rather is an anti pattern.
>> The evidence I've brought to this discussion shows that the most widely used
>> and depended upon libraries heavily favor the pattern.
> That's not necessarily a contradiction. ;)
That might seem a little bit mean. Let me help :-).
If we had "fluent syntax", say Dave's
variant, all along, would |this|-return have been developed as a
pattern? Hard to know but the odds arguably go down. They don't go up.
A cascade syntax would help avoid the pigeon-hole problem face by
setters: RHS value, like assignment? |this| for chaining? If that could
be an unnecessary dilemma, we could spend our time on other things.
But we don't have cascade syntax in ES6. We are adding Map/Set/WeakMap.
So back to the dilemma.
More information about the es-discuss