Check required conditions before running code that depends on them.

Requirement Check

requirement_check.lua
local count = 
local ok = count > 0
local nextValue = "blocked"

if ok then
  nextValue = tostring(count + 1)
end

print("count=" .. count)
print("ok=" .. tostring(ok))
print("nextValue=" .. nextValue)
local count = 
local ok = count > 0
local nextValue = "blocked"

if ok then
  nextValue = tostring(count + 1)
end

print("count=" .. count)
print("ok=" .. tostring(ok))
print("nextValue=" .. nextValue)
local count = 
local ok = count > 0
local nextValue = "blocked"

if ok then
  nextValue = tostring(count + 1)
end

print("count=" .. count)
print("ok=" .. tostring(ok))
print("nextValue=" .. nextValue)
precondition Preconditions make the success path explicit and keep invalid inputs from reaching later calculations.