• sebsch@discuss.tchncs.de
    link
    fedilink
    arrow-up
    6
    arrow-down
    3
    ·
    8 hours ago

    I never understood that argument. If you can be sure the type is a collection (and this you always should) not list is so moch easier to read and understood than the length check.

    • flatbield@beehaw.org
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      5 hours ago

      Compact does not mean easier to understand. They are different tests. The point is, do not make code less readable for speed unless speed matters. I am not going to argue which is more readable in any specific case. That is up to the developer.

    • Nalivai@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      8 hours ago

      How many elements in that list? Ah, it’s not list. It’s list, of course, we checked. But it’s not.