Сравнение строк

Простые типы / Строки

local first = "A"
local second = "B"
local third = "A"

local are_equal1 = first == second
-- are_equal1 = false

-- ~= is "not equal"
local not_equal = first ~= second
-- not_equal = true

local are_equal2 = first == third
-- are_equal2 = true

local more_than = first > second
-- more_than = false

-- Ignore case: lower the text first
local same_ignore_case = first:lower() == "a"
-- same_ignore_case = true

-- Text order, not numeric
local text_less = "10" < "9"
-- text_less = true

-- Byte order: all capitals come before lowercase
local caps_first = "Z" < "a"
-- caps_first = true

print("are_equal1 = " .. tostring(are_equal1))
print("not_equal = " .. tostring(not_equal))
print("are_equal2 = " .. tostring(are_equal2))
print("more_than = " .. tostring(more_than))
print("same_ignore_case = "
      .. tostring(same_ignore_case))
print("text_less = " .. tostring(text_less))
print("caps_first = " .. tostring(caps_first))