212

It happened! It finally happened.

I got to use the XOR operator today, for the first time in my 10 years of development.

Now I feel complete. I am senior developer now!

Comments
  • 44
    Congratulations!

    I sometimes do a double XOR just to throw off whomever is reading my code.
  • 4
    Lucky dev! you can now live in peace lol
  • 1
    If you like using xor that much, you could try the cryptopals coding challenges ^_^
  • 1
    😄
  • 4
    Awesome, what was the use case?
  • 1
    I guess you never encrypted your strings before then
  • 8
    Use case:

    I wanted to sort an array by its keys, some keys were strings, some integers. I needed to sort them ascending, which would place the numerical indexes before the steering indexes. But I needed the numerical indexed after the string indexes.

    So this is my compare function:

    function ($keyA, $keyB) {
    if(is_numeric($keyA) xor is_numeric($keyB)) {
    return $keyB <=> $keyA;
    }
    return $keyA <=> $keyB;
    }
  • 6
    Here in Germany, all major hosters charge extra for legacy php 5 support. That makes it pretty easy to convince my clients to upgrade.
  • 0
    Am I the only one who uses bitwise operators all the time? They are super useful, and at least for xor and cryptography, required many times. But even "and" and "or" are super useful!
Add Comment