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, <myemailu...@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 <e...@qfox.nl> wrote: > >> On Mon, Aug 10, 2015 at 3:50 AM, <myemailu...@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@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss