Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ルア 5.3
これは機能しません。なぜですか? テーブルに対して短い呼び出しフォームが機能しないのはなぜですか?
t = { "a", "b", "c" } s = t:concat()
これは動作します...
s = table.concat(t)
ライブラリは、そのstring関数をすべての文字列で共有されるメタテーブルにエクスポートします。str:upper()そのため、 のように使用できますstring.upper(str)。
string
str:upper()
string.upper(str)
table図書館の場合はそうではありません。メタテーブルを手動で設定する必要があります。たとえば、これは機能します:
table
local t = { "a", "b", "c" } t.__index = table setmetatable(t, t) local s = t:concat() print(s) -- abc