Original Post
Hey, I'm curious about the efficiency difference between a comparison and an assignment. If I have an array of several objects, and I want to give all that have an attribute X the attribute Y (which is the attribute that non-X elements have, i.e, the elements that are not X are Y). Would it be more efficient to go through the array and assign Y to those that are X, or simply assign Y to all elements (even though there may be some that are already Y)? I bet the difference is minimal, but I'm just curious. To make this more clear, I'll consider a binary case. Imagine there's an array of [1, 0, 1, 1, 1, 0], and I want to set the 1s to 0s. Should I just go through the array, and set all of them to 0, or look for ones and set them to 0? Thanks, Jengerer