For example, div/2
is an existing function in the Kernel
module. I want to call my own div/2
function instead of the Kernel.div/2
function.
You can un-import a function in Kernel
by explicitly importing Kernel
and excluding the functions you don't want with the except
option:
defmodule A do
import Kernel, except: [div: 2]
def div(a, b), do: a * b
def do_div, do: div(3, 4)
end
IO.inspect A.do_div()
Output:
12
You can also call
<module-name>.div/2
from inside your <module-name>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With