9

Despite having programmed for quite a few years now, for some reason I keep thinking the filter function's predicate needs to be true for things you want to exclude, not things you want to include...

catalogue.filter(i -> i.quantity < 1)

was what I just tried to do when I wanted to fetch all the items still in stock... Why am I like this?

Comments
  • 1
    Check yourself for dyslexia.

    I have the same thing Everything that requires symmetry is super hard for me and now they want me to do geometry ><
  • 3
    Yes, the term filter implies the same for me. However it‘s more convenient if it’s "true" for "keep it", so I’m fine with how it is.
  • 3
    because it's asking if the thing should be filtered

    filter means exclude

    like a coffee filter excludes most of the coffee

    so if you say "yes" you mean to exclude

    if it was named "pass" or something it would be less fucky

    I always have to double-check I got it right
  • 2
    @antigermgerm might explain a lot of your politics. you might be having principles dyslexia I guess
  • 1
    I always forget how to write switch() case blocks
  • 1
    Makes sense. A filter catches particular particles it's designed for [by size, by shape, by polarity, etc], and lets the rest flow through. In code filters also are designed to detect particular entities, but contrary to irl filters, they let those entities flow through.

    Makes sense. Never thought about filters being inverse in programming. They act more like select() than filterOut()
  • 0
    @jestdotty wut?

    The right became the right because the people who wanted the king back sat on the right of the parliament.

    At least I'm not a submissive peasant standing for tyranny.
  • 0
    @jestdotty imagine if we didn't cut the king's head. We would still be living in the middle age like the british.
  • 0
    @chatgpt if you filter on sand, are you keeping the sand?
  • 0
    @retoor
    Filtering on sand typically means removing impurities or particles that are larger than the sand grains themselves. So, in this context, filtering on sand involves keeping the sand and separating it from other substances or debris.
  • 0
    When filtering, sometimes you want to include, sometimes you do it because you want to exclude.

    Filter does not really defines result I guess.
  • 1
    @retoor it does define it implicitly by interpreting the predicate "true" as "keep that".
    Of course this can easily be changed to "exclude" by simply negating the predicate.
  • 2
    @Lensflare

    #define false 1

    #define true 0

    Then just use those to test against. Might create issues elsewhere though.
  • 2
    Maybe true in the filter means it gets passed the barrier. Opt in I guess.
  • 1
    @Demolishun
    #define true rand()%100
Add Comment