Both, either or any
I recently was adding functionality to a part of our product that was full of lines like this:
- lBool_vert_in = this.IsBoathBitsSet(iArrAllow[key], iArrDeny[key],
- top.mTDSDefines_CheckInAction);
Later I also needed to know what the function does. At first I thought the name was actually pretty self-describing. But I couldn't explain the behavior I was seeing in a part of the code that invoked this function.
- this.IsBoathBitsSet = function(iBit1Value, iBit2Value, iDefineType)
- {
- return (
- (
- (iBit1Value & iDefineType)||
- (iBit2Value & iDefineType)
- ) == iDefineType )
- }
I was thinking of renaming the function. But what shuld I rename it to? At first I was thinking IsEitherBitSet, since it returns true if either bit it set. But that is also not entirely correct. Since it also returns true if both bits are set.
So maybe it should be called IsAnyBitSet. What do you think? How do you translate boolean operators into English?
No comments:
Post a Comment