Brendan Eich wrote:
Let's look at what CoffeeScript requires to avoid this exception:
$ cat /tmp/z.coffee
person = {}
person?.getName?()
$ ./bin/coffee -p /tmp/z.coffee
(function() {
var person;
person = {};
if (person != null) {
if (typeof person.getName === "function") {
person.getName();
}
}
}).call(this);
$ ./bin/coffee /tmp/z.coffee && echo "no throw"
no throw
But of course, to the point that "it's rare to have a maybe-method
called on a maybe-object", the minimum required by CoffeeScript here is
just:
$ cat /tmp/z.coffee
person = {}
person.getName?()
$ ./bin/coffee -p /tmp/z.coffee
(function() {
var person;
person = {};
if (typeof person.getName === "function") {
person.getName();
}
}).call(this);
$ ./bin/coffee /tmp/z.coffee && echo "no throw"
no throw
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss