-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Integrate Lua with C++
By :

While you may well know that C++ is a statically-typed language, Lua is a dynamically-typed language. In C++, when you declare a variable, you give it a clear type. In Lua, each value carries its own type, and you do not need to explicitly specify a type. Also, you do not need to define a global variable before referencing it. Although you are encouraged to declare it – or better yet, use local variables. We will learn about local variables later in this chapter.
In Lua, there are eight basic types: nil, boolean, number, string, userdata, function, thread, and table.
We will learn about six of these in this chapter: nil
, boolean
, number
, string
, table
, and function
. Let’s try some before we go into the details:
Lua 5.4.6 Copyright (C) 1994-2022 Lua.org, PUC-Rio > a nil > type(a) nil > a = true > type(a) boolean > a = 6 > type(a) number > a = "bonjour" > type(a) string
What happens here is as follows:
...