- Lua Quick Start Guide
- Gabor Szauer
- 159字
- 2021-08-05 10:30:39
Defining a function
A function declaration starts with the function keyword. After the function keyword, you provide the function name. The name of the function follows the same naming rules as the name of a variable.
After the name of your function, you have to provide a list of parameters. Parameters are variable names enclosed in parentheses (). The list of parameters may be empty if a function needs no parameters, in which case only opening and closing parentheses are given—().
Once you have declared the list of parameters, you may write the body of the function. The function body is a chunk of code, so like other chunks you need to close the body with the end keyword. The following code demonstrates a simple function:
function PrintSomething()
text1 = "hello"
text2 = "world"
print (text1 .. ", " .. text2)
end
This function definition can be broken down into the following parts:

- Spring Cloud Alibaba微服務(wù)架構(gòu)設(shè)計(jì)與開發(fā)實(shí)戰(zhàn)
- Java EE 6 企業(yè)級(jí)應(yīng)用開發(fā)教程
- TypeScript實(shí)戰(zhàn)指南
- Java 9模塊化開發(fā):核心原則與實(shí)踐
- Apache Spark 2.x for Java Developers
- 深入理解Elasticsearch(原書第3版)
- 平面設(shè)計(jì)經(jīng)典案例教程:CorelDRAW X6
- Python商務(wù)數(shù)據(jù)分析(微課版)
- Qt 4開發(fā)實(shí)踐
- Learning Concurrency in Python
- 視窗軟件設(shè)計(jì)和開發(fā)自動(dòng)化:可視化D++語(yǔ)言
- Mastering Bootstrap 4
- 深入理解Java虛擬機(jī):JVM高級(jí)特性與最佳實(shí)踐
- 零基礎(chǔ)PHP從入門到精通
- 大話代碼架構(gòu):項(xiàng)目實(shí)戰(zhàn)版