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

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:

主站蜘蛛池模板: 临泉县| 武鸣县| 宁陵县| 松原市| 隆回县| 巨鹿县| 高青县| 石屏县| 陇川县| 策勒县| 紫阳县| 西华县| 山东省| 永平县| 北宁市| 黑河市| 弋阳县| 新田县| 广州市| 双辽市| 高雄市| 隆化县| 巴青县| 安庆市| 北票市| 贵州省| 板桥市| 沾益县| 石首市| 台安县| 镇雄县| 山西省| 阳东县| 乌苏市| 鄂州市| 屏东市| 常山县| 类乌齐县| 泰顺县| 清镇市| 屯门区|