「Lua入門」if文に論理積(and)を使うサンプル

構文
if 左の条件 and 右の条件
左の条件と右の条件が両方ともtrueの場合、trueになります。それ以外はfalseです。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
x = 8
if x == 8 and x < 10 then
print("123 yes")
else
print("456 no")
end
x = 8 if x == 8 and x < 10 then print("123 yes") else print("456 no") end
x = 8

if x == 8 and x < 10 then
      print("123 yes") 
else
      print("456 no")
end

実行結果
C:\study\lua>lua 11.lua
123 yes

Lua

Posted by arkgame