lua是動態型別語言,變數沒有型別定義,每個變數都可以包含任何型別的值。
lua的基本型別:boolean、number、string、userdata、function、thread、table
定義幾個變數並檢視他們的型別,如下:
testbool=true --boolean
testnum=12.3 --number
str="hello world" --string
p=print --print是lua的輸出函式
tab={} --定義了乙個空得table
使用type檢視變數的型別:print(type(testbool))
print(type(testnum))
print(type(str))
print(type(p))
print(type(tab))
(注:print為lua的輸出函式)
輸出:
boolean
number
string
function
table
Lua學習(一)型別和值
color blue 型別和值 color color blue 1 nil 空 color 未被賦值的變數預設值都為nil,將變數賦值nil等同刪除變數 color blue 2 boolean 布林 color false和nil都為 假 0和空字串 都為 真 color blue 3 numb...
Lua基礎 型別和值(一)
lua是乙個動態型別的語言,沒有型別定義,每個值都有自己的型別。lua有8個基本型別,nil,boolean,number,string,userdata,function,thread,table,利用type函式可以列印出乙個給定值的型別。注意最後一行,無論x為什麼值,結果一定是string,因...
C 學習(一)型別轉換
1.型別轉換按方式分為隱式轉換和顯式轉換。隱式轉換 由編譯器自動完成,無需使用者干預。顯式轉換 採用一定的形式進行轉換 型別名 資料 c中 型別名 資料 2.關於轉換建構函式 建構函式的一種,主要用於型別轉換,格式嚴格規定為單引數建構函式。例 complex類 complex double r in...