Try if (!(@array[0] | @array[1])) instead
Don't, for the reason Marshall++ explained. Micro-optimising code to avoid typing a few characters does not improve performance, and makes maintenance a nightmare (if overused).
Also, your code assumes integers, right? I would have to look up the binary representation(s) of a float 0.0 to see if all bits are 0 there. If not, this probably won't work, resulting once again in wrong results (false negatives, in this case). Maybe floats depend on the CPU and / or math emulation library used, so the result would also depend on the machine it is running on. No, thanks. I prefer code that does not make me think about such issues.
For two or three elements, explicitly compare the elements. For more, see my generalised posting.
Playing golf is a completely different story, but then, the array's name would not be five letters long.
Alexander
In reply to Re^4: Check multiple array elements for a single condition
by afoken
in thread Check multiple array elements for a single condition
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |