【Lua】【1】探讨Lua基础知识

--//===========================第一章
--[[
print("------------第一章 -----------")
print("Hello  lisong")
print(2+2)
print(3-1)
print(3*2)
print(5/2)
print(5%3)
print(5^2)
print(-(5-1))
print(2*(1+2+3)^3)    --  相当于 2*(6^3)=2*216

print(11^15)
print(23000000000000001)
print(1.2345e5)
print(1.234512e5)
print(1.234E+05)
print(1234E-4)
print(1234*(10^-4))
print(0xf)
print(0x10)
print(0x11)
print(0x10a4)

pointTwo=1.2-1.0
print(pointTwo<0.2)
print(pointTwo>0.2)
print(type("Hello"))
print(type(2))
print(type(1.2))
print(type(2>23))
print(type(true))
add=function ()
return   10
end
print(type(add))

a={}
print(type(a))
print(type(printw))
a={ [1]=1,[2]=2}
a="hh"
print(type(a))

x=4
y=3
print(x+y)
f00=13
print(f00)
f00="Java"
print(f00)
x=4
y=x
print(x)
print(y)
x=5
print(x)
print(y)


a={}
a[1]=3
a[2]=4
b=a
print(a[1].."  "..a[2])
print(b[1].."  "..b[2])
a[1]="Hello"
b[2]=2.3
print(a[1].."  "..a[2])
print(b[1].."  "..b[2])
x,y= 3,{ age="24",sex="man"}
print(x.."  "..y.age.."  "..y.sex)
add = function  (a,b,c)   return  a^2,b^2,c^2   end
x,y,z=add(1,2,3)
add  function  (a,b,c)  a,b,c=2,3,4 return  2,3,4   end
print(x.." "..y.." "..z)
print(1==1)
print(1<2)
print(1>2)
print(1~=1)
print(1>=0)
print((1.2-1.0)~=0.2)
print(1=="JJJ")
print("hello"=="hello")
print(true~=true)
a={
    [1]=2
}
b=a
print(a==b)
a=1
add = function  (a,b,c)   return  a^2,b^2,c^2   end
kkk= function  (a,b,c)   return  a^2,b^2,c^2   end
kkk=add
print(add==kkk)
print(1=="mm")
print("hellp"<"p")
print("hello"<"hella")
print("abcd"<"abcde")
x=tostring(13)
print(type(x))
y=tonumber("1e4")
print(type(y))
z='ni haoo \' mdlam '
print(z)
print(type(z))
w="Hello \" moni"
print(w)
--str=\[\[Hello\]\]
print(#str)
print(type(string.len(str)))
print(type(#str))
print("J\195\180ger")
print(true  and  true)
print(true and  false)
print(false  and  false)
print(false  and  true)
print(true  and  "Hje")
print( 0  and  -4)
print(false  and 5)
print()
print(true  or  true)
print(true or    false)
print(false  or    false)
print(false  or    true)
print( 5  or  4)
print(false  or  4)
print( false or  0  or "Hello")
str=[===[  [=[ndkandks
    <head>
    </head>
    ]===]
  ]=]
print(str)
print(not  true)
print(not 4)
print(not false)
print(not (false  or  "Hello"))
if  not (false  or  "Hello")  then
    print("true")
else
    print("false")
end
]]
a={
    name="foride"
}
if  a.name  then
    print("true")
else
    print("false")
end
print(c==nil)
print(type(b)=="nil")     --   true
print(type(a)=="table")  --true
 
do
local  i=10
print("Inside:"..i )
end
print(i)
 

 
--块
 

 
local  j=10
print(j)
print(type(j))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值