# Built-in global functions
Function Function Type(Return Type(List)) Description
print: (...) => nil Standard output parameter, table or function encountered, output type name: 0000000000000000
pprint: (...) => nil The result of the standard output parameter tojsonstring
type: (object) => string According to the string corresponding to the type of the output parameter
at runtime, number, string, table, function and Boolean are returned. When
other types of parameters are encountered, the corresponding string in the
previous five types is returned
比如:
let a1 = 1
let a2 = type(a1) -- a2值是'number',运行时的int和number类型,type函数返回结果都是'number'
let b1: object = 1
let b2 = type(b1) -- b2值是'number',因为使用的是运行时类型
type Person = {}
let c1 = Person()
let c2 = type(c1) -- c2值是'table',运行时的table和record类型,type函数返回结果都是'table'
require: (string) => object 引用其他的模块,不当成合约引用,被引用的模块加载后return的结果作为require函数的结果
emit: (string, string) => nil Event event is thrown and recorded by blockchain
exit: (object) => object To end this operation, the parameter is the end code
pairs: (table) => object Returns the table iterator. The traversal order is to traverse the array part
first and then the hash table part. The number key of the hash table part is
traversed before the key of the string, which is also the key of the string
type. The short string is before the long string, and the key of the same
length string is from small to large in ASCII character order
ipairs: (table) => object Iterator that returns the array part of table
error: (...) => object Error
getmetatable: (table) => table
tostring: (object) => string For table and function, return type name: 0
tojsonstring: (object) => string Convert the parameter to JSON string, return function: 0 for function, and
for nested table in table, if there is circular reference, use 'address' instead
of value. JSON will compare the character order of each character according
to the character order of key first, then from left to right. Return '[]' for null
able
tonumber: (object) => number Turn the parameter to number, encounter the string, read the number from the string, encounter the unresolved string or table or function, return nil
tointeger: (object) => int Convert the parameter to an integer, encounter a string, read an integer from the string, encounter a string or table or function that cannot be parsed, and return nil l
todouble: (object) => number Convert parameter to number type, return nil when encountering an unresolved value
toboolean: (obj) => bool Convert parameter obj to a Boolean value. If obj is false or nil, it returns false. Otherwise, it returns true
totable: (object) => table Use the parameter as a table. If the parameter is not a table and returns nil,
it is mainly used for static type conversion during compilation
next: (...) => object Move iterator to next step
rawequal: (object, object) => bool Directly compare whether two values are the same value (= = comparison will take precedence__ eq__ Metafunction to compare)
rawlen: (object) => int Get the array part length of a table directly
rawget: (object, object) => object Get a property of a table directly
rawset: (object, object, object) => nil Set a property of a table directly
select: (...) => object When index is a number, all parameters with index greater than index will be returned: for example, select (2, "a", "B") will return "B". When index is "X", the total number of parameters (excluding index) will be returned
setmetatable: (table, table) => nil Set table meta table
fast_map_get: (string, string)=>object Get the storage value of fast map
fast_map_set: (string, string, object)=>void Set the storage value of fast map
← controlflows module →