go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) In reply to Re^4: Check multiple array elements for a single condition
by afoken
|
|