A ruler with the logo for the Lua Programming language

    • Kerb@discuss.tchncs.de
      link
      fedilink
      arrow-up
      26
      ·
      edit-2
      1 year ago

      thats probably taking the piss with how lua handles array indexing.

      in most programming languages,
      the first element of an array is element 0,
      in lua arrays start with element 1.

      imo it kinda makes sense,
      but it causes confusion because it goes against established conventions

  • ezchili@iusearchlinux.fyi
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 year ago

    There’s a syntax for indexing starting from 0, it’s

    *(&arr+0) to *(&arr+(n-1))

    For the rest of us who are manipulating sets of values and not offsets on pointers and aren’t delusionally attached to conventions, there’s arr[1] to arr[n]