msg:context_exists
Last updated March 2020
Name
msg:context_exists — Check if a context variable exists
Synopsis
msg:context_exists(type, key);
type: numeric key: string
Description
Check if a context variable exists. Legal values for type
are:
-
msys.core.ECMESS_CTX_MESS
-
msys.core.ECMESS_CTX_CONN
local e = msg:context_exists(msys.core.ECMESS_CTX_MESS, 'key')
This function returns 1
if the key exists and 0
if the key does not exist.
The return value of this function should always be compared explicitly. For example:
local e = msg:context_exists(msys.core.ECMESS_CTX_MESS, 'key')
if e == 1 then
-- do something here that depends on the key existing
end
Note that Lua treats the numeric value 0
as true, which can be confusing.
Because this function is in the msys.core
namespace, an explicit require('msys.core')
is not necessary.
See Also
Was this page helpful?