- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Michelle M. Fernandez
- 229字
- 2021-07-23 19:37:18
Types of values
Lua is a dynamically typed language. There is no defined variable type in the language. This allows each value to carry its own type.
As you have noticed, values can be stored in variables. They can be manipulated to give a value of any type. This also allows you to pass arguments to other functions and have them returned as results.
The basic types of values that you'll deal with are as follows:
- Nil: This is the only type whose value is
nil
. Any uninitialized variable hasnil
as its value. Like global variables, it isnil
by default and can be assignednil
to delete it. - Boolean: This type has two values:
false
andtrue
. You will notice that conditional expressions considerfalse
andnil
as false and anything else astrue
. - Numbers: These represent real (double-precision, floating-point) numbers.
- String: This is a sequence of characters. 8-bit characters and embedded zeroes are allowed.
- Tables: These are data structures in Lua. They are implemented by an associative array, which is an array that can be indexed not only with numbers, but also with strings or any other value, except
nil
(more information on this later in this chapter called Tables). - Functions: These are known as first-class values of Lua. Typically, functions can be stored in variables, passed as arguments to other functions, and returned as results.
推薦閱讀
- Java入門經典(第6版)
- Learning Spring 5.0
- 精通搜索分析
- Python測試開發入門與實踐
- ASP.NET動態網頁設計教程(第三版)
- Processing互動編程藝術
- 21天學通C++(第6版)
- Hands-On Swift 5 Microservices Development
- KnockoutJS Starter
- 從零開始:UI圖標設計與制作(第3版)
- 網絡數據采集技術:Java網絡爬蟲實戰
- Learning Splunk Web Framework
- Python Projects for Kids
- 樹莓派開發從零開始學:超好玩的智能小硬件制作書
- Learning ROS for Robotics Programming