欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

lua5.1 和 5.2 關于 sequence 的定義變化,對#t

系統 2110 0

引子

環(huán)境 lua 5.2

? a = {}
? for i=1,2 do a[i] = i*3 end


? a[4] = 11;
? print(a[#a])


? ---print 11


-----------------------------------


? a = {}
? for i=1,3 do a[i] = i*3 end


? a[5] = 11;
? print(a[#a])
??
? ----print 9

---------------------------------

#a ?第一個的值是4 ? 第二個的值是3 ? ?

依據我之前從書中看到的知識點來看的話 ??#a ?第一個的值是2 ? 第二個的值是3 ? ?才對啊 ?

為啥呢 ?

剛開始入門,源碼部分就跳過吧,又沒有合適的關鍵詞搜索,僅僅能到大嬸群里問了

一會兒 ? 大神來了 ? 給了個牛逼的解釋?

大嬸:

?5.1?和?5.2?關于?sequence?的定義有變化.?
?5.1?的
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?(that?is,?
the?usual?meaning?of?string?length?when?each?character?is?one?byte).

The?length?of?a?table?t?is?defined?to?be?any?integer?index?n?such?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?a?given?n,
?its?length?is?exactly?that?n,?the?index?of?its?last?value.?If?the?array has?"holes"?(that?is,?nil?values?between?other?non-nil?values),?then?#t?can?be?any?of?the?indices?that?directly?precedes?a?nil?value?(that?is,?
it?may?consider?any?such?nil?value?as?the?end?of?the?array).



?5.2?的
3.4.6?–?The?Length?Operator

The?length?operator?is?denoted?by?the?unary?prefix?operator?#.?The?length?of?a?string?is?its?number?of?bytes?(that?is,
?the?usual?meaning?of?string?length?when?each?character?is?one?byte).

A?program?can?modify?the?behavior?of?the?length?operator?for?any?value?but?strings?through?the?__len?metamethod?
(see?§2.4).

Unless?a?__len?metamethod?is?given,?the?length?of?a?table?t?is?only?defined?if?the?table?is?a?sequence,?that?is,
?the?set?of?its?positive?numeric?keys?is?equal?to?{1..n}?for?some?integer?n.?In?that?case,?n?is?its?length.?Note?that?a?table?like

?????{10,?20,?nil,?40}
is?not?a?sequence,?because?it?has?the?key?4?but?does?not?have?the?key?3.
?(So,?there?is?no?n?such?that?the?set?{1..n}?is?equal?to?the?set?of?positive?numeric?keys?of?that?table.)?Note,?however,?that?non-numeric?keys?do?not?interfere?with?whether?a?table?is?a?sequence.


從語言角度講,?lua?5.1?定義了?#?對數組取長度的約束.?而?lua?5.2?不嚴格定義了,僅僅說假設有?nil?就不確定


也就是說?lua?5.2?放寬了語言定義,同意實現更靈活
?
我:
非常高深啊???我得慢慢啃 ?


--[[高潮部分,直達G點]]
大嬸:
沒什么高深的,?lua?5.2?說,你有?nil?就別指望?#table 對




dun悟了......................level ? +1

lua5.1 和 5.2 關于 sequence 的定義變化,對#table取值的影響


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 99久久国产综合精品网成人影院 | 日韩成人av在线 | 日本高清视频www夜色资源网 | 久久久精| 黄色国产在线视频 | 久草在线视频资源站 | 一区二区三区日本在线观看 | 色悠悠久久久久 | 午夜在线播放视频 | 精品在线不卡 | 天天操天天插 | 欧美黑人乱大交 | 亚洲欧美日本在线观看 | 国产www色| 亚洲欧美国产另类视频 | 国产浮力第一页 | 久久男人视频 | 日本精品一区二区三区四区 | 国产午夜精品理论片免费观看 | 久草不卡视频 | 性高湖久久久久久久久aaaaa | 在线视频亚洲 | 久久久综合 | 国产精品福利资源在线 | 国产日韩一区二区三区 | 久久视频这里只精品3国产 色偷偷偷 | 999成人网 | 欧美福利大片 | 精品福利视频在线观看视频 | 色成人综合 | 91免费看 | 欧美色黄视频 | 成人国产在线观看 | 久久亚洲美女久久久久 | 精品视频在线免费看 | 欧美成人免费丝袜视频在线观看 | 亚洲h视频| 精品麻豆cm视频在线看 | 日韩欧美福利视频 | 人人澡人人澡人人澡 | 日韩精品一区二区三区四区视频 |