官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 自治县| 土默特左旗| 涞源县| 聂拉木县| 吐鲁番市| 青海省| 福建省| 南丰县| 富裕县| 静乐县| 洛阳市| 驻马店市| 成武县| 合肥市| 辽阳市| 阳泉市| 聂拉木县| 江陵县| 孟村| 梓潼县| 梨树县| 青龙| 吉安市| 姚安县| 沭阳县| 鄂伦春自治旗| 吐鲁番市| 普洱| 永清县| 肇东市| 南城县| 揭阳市| 白银市| 丰城市| 罗源县| 驻马店市| 渝北区| 全州县| 伊吾县| 高陵县| 融水|