See the book ProgrammingInLua? or ExpressionsTutorial for details on the special properties of these binary operators that allow them to work this way.
print('x is ' .. (x < 0 and 'negative' or 'non-negative')) -- this works!
2019-09-08, Хрень
2014-08-29, Хрень
------------------------------------------------------------------------
-- Lua developers forgot to add math.round function
------------------------------------------------------------------------
function minetest_hardcorebrix.math_round(val, decimal)
local exp = decimal and 10^decimal or 1
return math.ceil(val * exp - 0.5) / exp
end
2014-08-29, Хрень
------------------------------------------------------------------------
-- Lua developers forgot to add table.search function
------------------------------------------------------------------------
function minetest_hardcorebrix.table_search(table, element)
for key,value in pairs(table) do
if value == element then
return key
end
end
return false
end
2014-07-05, Хрень
print(tonumber(nil)) -- nil
2014-06-28, Чёрный список
local b, a = {} print(a) -- nil print(b) -- table: 0xafb07b20
2014-06-27, Чёрный список
local luaSucksBecause
luaSucksBecause["lua:sucks"] = true
20:17:09: ERROR[main]: ServerError: error in error handling