什么是“:"在卢阿的意思 [英] What does ":" mean in Lua

查看:77
本文介绍了什么是“:"在卢阿的意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Lua的新手,我从事项目工作,我在理解:"这个问题时遇到了一个问题,例如在手册中没有找到它,例如应该如何解释这段代码:

I'm new to Lua and I have work on project, I have an issue unterstanding what ":" I didn't found it on the manual for example how should interpret this piece of code :

res:template{
        main = 'functionform.html',
        functionjs = '_functionform.js',
        functionform = '_functionform.html'
    }

推荐答案

摘自第2.5.8节:

Lua中的函数调用具有以下语法:

A function call in Lua has the following syntax:

functioncall :: = prefixexp args

functioncall ::= prefixexp args

在函数调用中,将对第一个prefixexp和args进行求值.如果 prefixexp的值具有类型函数,则该函数称为 与给定的参数.否则,使用prefixexp调用"元方法 被调用,其第一个参数为prefixexp的值,其后为 通过原始调用参数(请参见第2.8节).

In a function call, first prefixexp and args are evaluated. If the value of prefixexp has type function, then this function is called with the given arguments. Otherwise, the prefixexp "call" metamethod is called, having as first parameter the value of prefixexp, followed by the original call arguments (see §2.8).

表格

functioncall :: = prefixexp`:´args

functioncall ::= prefixexp `:´ Name args

可用于调用方法".调用v:name(args)是语法糖 用于v.name(v,args),除了v仅被评估一次.

can be used to call "methods". A call v:name(args) is syntactic sugar for v.name(v,args), except that v is evaluated only once.

所以res:template{}res.template(res, {})相同.

这篇关于什么是“:"在卢阿的意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆