bool[] ba = [1,0,1,0,1,1,0,1,0,1]; bool[] bb = [1,0,1,1,0]; auto a = BitArray(ba); auto b = BitArray(bb); BitArray c = a; c.length = 5; c &= b; assert(a[5] == 1); assert(a[6] == 0); assert(a[7] == 1); assert(a[8] == 0); assert(a[9] == 1);
bool[] ba = [1,0,1,0,1]; bool[] bb = [1,0,1,1,0]; auto a = BitArray(ba); auto b = BitArray(bb); a &= b; assert(a[0] == 1); assert(a[1] == 0); assert(a[2] == 1); assert(a[3] == 0); assert(a[4] == 0);
bool[] ba = [1,0,1,0,1]; bool[] bb = [1,0,1,1,0]; auto a = BitArray(ba); auto b = BitArray(bb); a |= b; assert(a[0] == 1); assert(a[1] == 0); assert(a[2] == 1); assert(a[3] == 1); assert(a[4] == 1);
bool[] ba = [1,0,1,0,1]; bool[] bb = [1,0,1,1,0]; auto a = BitArray(ba); auto b = BitArray(bb); a ^= b; assert(a[0] == 0); assert(a[1] == 0); assert(a[2] == 0); assert(a[3] == 1); assert(a[4] == 1);
bool[] ba = [1,0,1,0,1]; bool[] bb = [1,0,1,1,0]; auto a = BitArray(ba); auto b = BitArray(bb); a -= b; assert(a[0] == 0); assert(a[1] == 0); assert(a[2] == 0); assert(a[3] == 0); assert(a[4] == 1);
Support for operator op= for BitArray.