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

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:

主站蜘蛛池模板: 孟津县| 台湾省| 临潭县| 托克托县| 桐庐县| 宁化县| 栾城县| 桐梓县| 灵山县| 兴和县| 清镇市| 鄂伦春自治旗| 内乡县| 寿阳县| 柏乡县| 瑞昌市| 双江| 蒙阴县| 正镶白旗| 青川县| 隆化县| 开化县| 凤山县| 吉木乃县| 黄浦区| 龙州县| SHOW| 平度市| 隆安县| 保靖县| 南澳县| 新蔡县| 唐河县| 淮阳县| 浦县| 新乡市| 洪泽县| 沈阳市| 教育| 喜德县| 衡东县|