Existential operator (was: ||= is much needed?)
Jeremy Ashkenas
jashkenas at gmail.com
Tue Jun 19 12:37:58 PDT 2012
On Tue, Jun 19, 2012 at 3:33 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:
>
> > foo.bar?(args) <==> foo.bar?.call(foo, args)
> > fun?(args) <==> fun?.call(undefined, args)
>
> How are these equivalent? Won't fun?.call evaluate to undefined if fun is
> undefined and undefined(undefined,args) will throw...
>
>
... check out the compilation:
http://coffeescript.org/#try:fun%3F.call(undefined%2C%20args)%0A%0Awindow.method%3F.call(window%2C%20args)
It doesn't eagerly evaluate to undefined ... the value of the *entire*
expression is undefined if the chain is broken at the existential operator.
That's much of the point of soaks:
object.property?.i.can.keep.chaining.in.here.without.throwing.errors.if.property.is.undefined
;)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120619/03614a18/attachment.html>
More information about the es-discuss
mailing list