Elixir 语言将函数委派给另一个模块

示例

使用defdelegate定义函数,委托给另一个模块中定义的名称相同的功能:

defmodule Math do
  defdelegate pi, to: :math
end


iex> Math.pi
3.141592653589793