小编Yuk*_* Du的帖子

Lua中调用绑定方法时字符串的括号有什么用?

我是 的初学者Lua,我对().

这里有一些关于 的例子Lua5.3

a = '%s %s'
a:format("Hello", "World")             -- Hello World
'%s %s':format("Hello", "World")       -- stdin:1: unexpected symbol near ''%s %s''
('%s %s'):format("Hello", "World")     -- Hello World

type(a) == type('%s %s')               -- true
getmetatable(a)                        -- table: 0x1f20bf0
getmetatable('%s %s')                  -- table: 0x1f20bf0 for any other hard coded strings 
Run Code Online (Sandbox Code Playgroud)

题:

  1. ()对硬编码字符串做了什么?
  2. 否则,只有语法错误?:D

lua

4
推荐指数
1
解决办法
374
查看次数

标签 统计

lua ×1