please add orEqual operator
joe
joeedh at gmail.com
Mon Aug 10 16:42:12 UTC 2015
Isn't this what switch statements are for? Perhaps a condensed operator
version of a switch would be useful?
if (a == 0 : 1 : 2) {
}
Or perhaps something similar to the set version, but without the set:
if (a of 1, 2, 3, 4, 5, 6) {
}
One could do this as a standard lib variadic function, I suppose:
if (select(a, 1, 2, 3, 4, 5, 6)) {
}
Cheers,
Joe
On Mon, Aug 10, 2015 at 6:09 AM, <myemailum14 at gmail.com> wrote:
> Thanks I'll be searching through archive, and yea i think this is
> something very simple and yet innovative.
>
> On Mon, Aug 10, 2015 at 3:55 AM, Peter van der Zee <ecma at qfox.nl> wrote:
>
>> On Mon, Aug 10, 2015 at 3:50 AM, <myemailum14 at gmail.com> wrote:
>> > Isn't
>> > prop ||= 0;
>> > better than
>> > prop = prop || 0;
>> > and it can be even defined like this.
>> > prop ||= var1 ||= var2 ||= 0;
>> > but then i dont know how we can use it ike this
>> > if (num == 3 ||=4 ||=6)
>>
>> Sounds like you want two operators; `||=` for the compound assignment
>> case and `||==` and `||===` for the "compare the RHS to the LHS of the
>> last `===` or `==` op", or something like that. Defining a single op
>> for both of these cases is likely to lead to ambiguity.
>>
>> The `||=` (and `&&=`) case has been discussed a couple of times, look
>> in the esdiscuss archives.
>> I'm sure something like `||==` has been discussed too though I don't
>> recall it myself. I tend to use switches myself for this in case perf
>> is an issue.
>>
>> - peter
>>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150810/e7bc1b13/attachment.html>
More information about the es-discuss
mailing list