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

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:

主站蜘蛛池模板: 长垣县| 新闻| 荣成市| 元阳县| 台江县| 临潭县| 电白县| 肥东县| 准格尔旗| 平陆县| 屯留县| 内江市| 岳池县| 武冈市| 三门县| 尉氏县| 达拉特旗| 西林县| 化德县| 大渡口区| 治县。| 马鞍山市| 吐鲁番市| 霍林郭勒市| 潞城市| 阿勒泰市| 横山县| 广水市| 伽师县| 靖宇县| 土默特左旗| 北安市| 洮南市| 韶关市| 土默特右旗| 乃东县| 祁阳县| 屏山县| 岳阳县| 开化县| 桐城市|