--- title: nil - 缺失值 summary: nil 表示没有值。将表字段设为 nil 会删除该字段。返回 nil 与不返回任何值的结果数量不同。 section: reference kind: guide status: reference updated: 2026-10-26 tags: ["API","X4"] sources: ["https://wiki.egosoft.com/X4%20Foundations%20Wiki/Modding%20Support/","https://www.lua.org/manual/5.1/manual.html","https://luajit.org/ext_ffi_api.html"] --- ## 含义 nil 表示没有值。将表字段设为 nil 会删除该字段。返回 nil 与不返回任何值的结果数量不同。 ## 示例 ```lua local function empty() end local function one_nil() return nil end local a = select("#", empty()) -- 0 local b = select("#", one_nil()) -- 1 ``` **运行效果:** 没有结果,一个零的结果数量不同. 这段段没有打印或写日志信息. 显示的值是示例的预期结果. ## 方法与相关调用 [API 参考](wiki:api-index).