> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# filtergc

> 搜索匹配所提供 filters 的 live garbage-collected tables 或 functions。filterType 必须是 "table" 或 "function"。options 必须是 table。

<div className="real-function-page">
  ```lua theme={null}
  filtergc(filterType: string, options: table, returnOne?: boolean): table | function | nil
  ```

  ## 参数

  <ParamField path={"filterType"} type={"string"} required>
    要搜索的 GC object type。该值会转换为 lowercase，并且必须是 "table" 或 "function"。
  </ParamField>

  <ParamField path={"options"} type={"table"} required>
    Filter table。function searches 读取 Name, Hash, StartLine, IgnoreExecutor, IgnoreSyn, Environment, Constants, Upvalues。table searches 读取 Metatable, Keys, Values, KeyValuePairs。
  </ParamField>

  <ParamField path={"returnOne"} type={"boolean"}>
    Optional optional boolean handling flag。为 true 时，返回第一个 matching object 或 nil，而不是 array table。
  </ParamField>

  ## 返回值

  <ResponseField name={"result"} type={"table | function | nil"}>
    当 returnOne 为 false 或 omitted 时，返回 array table of matches。当 returnOne 为 true 时，返回第一个 matching table/function object 或 nil。
  </ResponseField>

  ## 示例

  Find GC tables by key filters without relying on result order.

  ```lua theme={null}
  local marker = {
      RealDocsMarker = true,
  }

  local matches = filtergc("table", {
      Keys = { "RealDocsMarker" },
  })

  for _, value in ipairs(matches) do
      if value == marker then
          print("found marker")
          break
      end
  end

  local first = filtergc("table", {
      Keys = { "RealDocsMarker" },
  }, true)

  print(first ~= nil)
  ```
</div>
