11

So - A && B == B && A ?
Not according to my mother. She seems to think that "eat the rice and I'll give you dessert" is different from "give me dessert and I'll eat the rice"

Comments
  • 3
    If you don't eat that rice, you'll eat nothing at all! You have five minutes!
  • 0
    Asynchronous much? We live in a post-truth era so you can use that as an argument right there...
  • 7
    No, your situation is A => B == B => A, which is not true
  • 0
    Something wrong with your rice?
  • 3
    From the computer's point of view, A && B != B && A.
    When it checks A && B, if A is already false, then it has no reason to check B anymore, and if B is a function it will not be run. Vice versa.

    Example (Java):
    String X = null;
    // A: X != null
    // B: X.equals("Something")

    // A && B
    X != null && X.equals("Something")
    /* Returns false because A is false, no more need to evaluate and check B. */

    // B && A
    X.equals("Something") && X != null
    /* NullPointerException because a method cannot be executed on null. */
  • 0
    @leduyquang753 nice, but not true for all languages (PHP, I think, for example)
  • 0
    @DustInCompetent no chocolate
  • 1
    from a parents point of view it is more like
    A && B != B || A
    because more often than not it's becomes the procession of the second part where A doesn't matter if B was true already.
  • 0
    @erroronline1 so maybe B^A (xor)
  • 1
    Logic applied to life == realisation that life is an illogical mess governed by laws of logic for some reason. Go figure
  • 0
    @jnfsmile php does the same, i had this dilemma recently
Add Comment