Why do Lua arrays(tables) start at 1 instead of 0?

后端 未结 8 2127
情歌与酒
情歌与酒 2020-12-12 18:34

I don\'t understand the rationale behind the decision of this part of Lua. Why does indexing start at 1? I have read (as many others did) this great paper. It seems to me a

8条回答
  •  死守一世寂寞
    2020-12-12 19:13

    Perhaps a less significant point, but one I haven't heard mentioned yet: there is better symmetry in the fact that the first and last characters in a string are at 1 and -1 respectively, instead of 0 and -1.

提交回复
热议问题