• Zikeji@programming.dev
    link
    fedilink
    English
    arrow-up
    17
    ·
    3 days ago

    So if it has to be a number the question is - is the array of options, ['Fish', 'Bird'], 0-indexed or not? I guess 1 is the safest choice but not true to your actual choice.

    • wizardbeard@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      15
      ·
      edit-2
      3 days ago

      Just for you, I’d enter 18,446,744,073,709,551,616

      Explanation

      18,446,744,073,709,551,615 is the max value an unsigned 64-bit long value can store. It’s absurdly unlikely that any data indexing format supports this many indexes. Then I added 1 to it. 🫠

      For when you absolutely, positively, need to make sure you’re out of bounds.

      Negatives aren’t enough, because some programming languages allow you to index from the other end using negatives, so -1 is the final item.

      • porous_grey_matter@lemmy.ml
        link
        fedilink
        English
        arrow-up
        7
        ·
        3 days ago

        It’s Google forms. I’m pretty sure they’ll handle this case.

        Anyway, it’s not that unlikely, for example, python’s ints are arbitrary length (and convert to bigint under the hood when needed) and can just directly be used as hashmap/dictionary keys.