- Lua Quick Start Guide
- Gabor Szauer
- 159字
- 2021-08-05 10:30:39
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:

- Embedded Linux Projects Using Yocto Project Cookbook
- Learning LibGDX Game Development(Second Edition)
- Learning Data Mining with Python
- 編寫高質(zhì)量代碼:改善C程序代碼的125個建議
- Yocto for Raspberry Pi
- Python機(jī)器學(xué)習(xí)基礎(chǔ)教程
- Scala編程實戰(zhàn)(原書第2版)
- Scratch3.0趣味編程動手玩:比賽訓(xùn)練營
- 創(chuàng)意UI:Photoshop玩轉(zhuǎn)APP設(shè)計
- C++程序設(shè)計教程(第2版)
- Scratch從入門到精通
- INSTANT Apache Hive Essentials How-to
- Clojure編程樂趣
- Serverless從入門到進(jìn)階:架構(gòu)、原理與實踐
- TensorFlow.NET實戰(zhàn)