为什么这个语法有效:
if ({A=1,B=1,C=1})["A"] then print("hello") end
Run Code Online (Sandbox Code Playgroud)
虽然这不会:
local m = {string.sub(string.gsub("A,B,C,", ",", "=1,"),1,-2)}
if (m)["A"] then print("hello") end
Run Code Online (Sandbox Code Playgroud)
???
我认为这是因为字符串不是数组,但是如何将字符串("a,b,c")转换为数组({a=1,b=1,c=1})?