我不明白的Lua语法片段是什么意思?

2026-04-01 20:331阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计415个文字,预计阅读时间需要2分钟。

我不明白的Lua语法片段是什么意思?

我在使用基于Lua的产品,正在使用它们的API,并在其中遇到一些我不理解的语法。这是什么?这是Add函数的调用,如果参数是,那么输入参数是什么?——没有将这些应分配给变量的表达式输入——没有等号。

我正在使用基于Lua的产品,我正在使用他们的API,并且在那里有一些我不理解的语法.

这是什么?
它是Add的函数调用,如果是,那么输入参数是什么 – 没有将该表分配给变量输入 – 没有等号?

它是Add的函数定义 – 看起来很奇怪,没有任何实现并指定输入表中的内容?

添加包含表格的表格?我从未见过用括号而不是花括号创建的表格?

serviceDefinitions.Add( input { name="p1", baseType="NUMBER", description="The first addend of the operation" }, input { name="p2", baseType="NUMBER", description="The second addend of the operation" }, output { baseType="NUMBER", description="The sum of the two parameters" }, description { "Add two numbers" } ) 当调用只有一个参数是表或字符串的函数时,可以省略括号.从 manual:

我不明白的Lua语法片段是什么意思?

All argument expressions are evaluated before the call. A call of the form f{fields} is syntactic sugar for f({fields}); that is, the argument list is a single new table. A call of the form f'string' (or f"string" or f[[string]]) is syntactic sugar for f('string'); that is, the argument list is a single literal string.

这意味着以下函数调用有效:

somefunction({1,2,3,4}) somefunction{1,2,3,4}

或者,使用字符串:

print('hello!') print 'hello!'

本文共计415个文字,预计阅读时间需要2分钟。

我不明白的Lua语法片段是什么意思?

我在使用基于Lua的产品,正在使用它们的API,并在其中遇到一些我不理解的语法。这是什么?这是Add函数的调用,如果参数是,那么输入参数是什么?——没有将这些应分配给变量的表达式输入——没有等号。

我正在使用基于Lua的产品,我正在使用他们的API,并且在那里有一些我不理解的语法.

这是什么?
它是Add的函数调用,如果是,那么输入参数是什么 – 没有将该表分配给变量输入 – 没有等号?

它是Add的函数定义 – 看起来很奇怪,没有任何实现并指定输入表中的内容?

添加包含表格的表格?我从未见过用括号而不是花括号创建的表格?

serviceDefinitions.Add( input { name="p1", baseType="NUMBER", description="The first addend of the operation" }, input { name="p2", baseType="NUMBER", description="The second addend of the operation" }, output { baseType="NUMBER", description="The sum of the two parameters" }, description { "Add two numbers" } ) 当调用只有一个参数是表或字符串的函数时,可以省略括号.从 manual:

我不明白的Lua语法片段是什么意思?

All argument expressions are evaluated before the call. A call of the form f{fields} is syntactic sugar for f({fields}); that is, the argument list is a single new table. A call of the form f'string' (or f"string" or f[[string]]) is syntactic sugar for f('string'); that is, the argument list is a single literal string.

这意味着以下函数调用有效:

somefunction({1,2,3,4}) somefunction{1,2,3,4}

或者,使用字符串:

print('hello!') print 'hello!'