• cogman
    link
    fedilink
    arrow-up
    29
    arrow-down
    3
    ·
    5 hours ago
    1. Logic bug. isHuangBullshit is returning true if any statement is true. You want the opposite.

    2. Map<X, Boolean> is a Set, Use a set instead.

    3. Don’t use Boolean if null is never a possibility, just use boolean. The same is true of all the boxes for primitives. It’s a huge performance penalty to use Integer when int works. Not so much with Boolean but the principle is the same. You are forcing whoever sees your method to question whether or not you are going to get a null out of that method.

    The correct code should look like this:

    public boolean isHuangBullshit() {
       Set<String> false_statements = Set.of("a", "c", "e");
       return false_statements.isEmpty();
    }
    
    • marcos
      link
      fedilink
      arrow-up
      16
      ·
      4 hours ago

      You want the opposite.

      The OP literally codified the Huang’s answer. It’s you interpreting it wrong.