> ## 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.

# comparefunctions

> 通过 function identity 比较两个 function values。两个 arguments 都必须是 functions。该 function 返回 function identity(L, 1) == function identity(L, 2) 的 boolean result。它不比较 function bytecode, source, behavior, hashes, upvalues 或 newcclosure mappings。comparefunction 是同一个 function 的 alias。

<div className="real-function-page">
  ```lua theme={null}
  comparefunctions(func1: function, func2: function): boolean
  ```

  ## 别名

  * `comparefunction`

  ## 参数

  <ParamField path={"func1"} type={"function"} required>
    使用 function identity 转换的 first function value。
  </ParamField>

  <ParamField path={"func2"} type={"function"} required>
    使用 function identity 转换的 second function value。
  </ParamField>

  ## 返回值

  <ResponseField name={"equal"} type={"boolean"}>
    当两个 function values resolve 到同一个 function identity 时为 true；否则为 false。
  </ResponseField>

  ## 示例

  Compare two functions by their function identity.

  ```lua theme={null}
  local function sample()
      return "ok"
  end

  local same = comparefunctions(sample, sample)
  print(same)
  ```
</div>
