gpt4 book ai didi

Lua,表的大小(#table_name 或 table.getn(table_name),有时返回 0

转载 作者:行者123 更新时间:2023-12-02 08:34:39 32 4
gpt4 key购买 nike

#table_name返回非0值时?再说一遍,当 table.getn(table_name) 确实返回非 0 值时?

最佳答案

仔细阅读手册:

2.5.5 - The Length Operator

The length operator is denoted by the unary operator #. The length of a string is its number of bytes (thatis, the usual meaning of string length when each character is onebyte).

The length of a table t is defined to be any integer index nsuch that t[n] is not nil and t[n+1] is nil; moreover, if t[1] is nil,n can be zero. For a regular array, with non-nil values from 1 to agiven n, its length is exactly that n, the index of its last value. Ifthe array has "holes" (that is, nil values between other non-nilvalues), then #t can be any of the indices that directly precedes anil value (that is, it may consider any such nil value as the end ofthe array).

关于Lua,表的大小(#table_name 或 table.getn(table_name),有时返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10718273/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com