On 04/05/11 08:37, Sean Eagan wrote:
Hi Dave,
I'm more skeptical of this one. It's sort of treating empty arrays as falsey,
which they aren't. And I've never noticed a need for this. But that might just
be the BLUB principle in action. Do you have examples/use cases in mind?
Here's a hypothetical use case, hope this isn't stretching too much...
let Pizza = function(...toppings = ["pepperoni"]) {
this.toppings = toppings;
}
let pepperoni = new Pizza(), hawaiin = new Pizza("pineapple", "ham");
That's non-orthogonal. Now you don't have a way to create a Pizza with no
toppings.
If you want such defaulting, just do:
let Pizza = function(...toppings) {
if (toppings.length == 0)
toppings = ["pepperoni"];
this.toppings = toppings;
}
Waldemar
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss