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

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:

主站蜘蛛池模板: 永昌县| 铁岭县| 佛坪县| 桐梓县| 平凉市| 佛山市| 三亚市| 海南省| 色达县| 郧西县| 墨脱县| 漠河县| 垫江县| 平武县| 阿拉善左旗| 桃园县| 灵川县| 乐亭县| 四川省| 当雄县| 东乌| 色达县| 墨江| 金山区| 青铜峡市| 樟树市| 东乌珠穆沁旗| 旺苍县| 成都市| 林口县| 淮滨县| 新郑市| 弋阳县| 阳谷县| 宁阳县| 赫章县| 黑水县| 仁怀市| 长顺县| 金川县| 宜兴市|