Kernel.apply

You're seeing just the function apply, go back to Kernel module for more information.

Specs

apply((... -> any()), [any()]) :: any()

Invokes the given anonymous function fun with the list of arguments args.

If the number of arguments is known at compile time, prefer fun.(arg_1, arg_2, ..., arg_n) as it is clearer than apply(fun, [arg_1, arg_2, ..., arg_n]).

Inlined by the compiler.

Examples

iex> apply(fn x -> x * 2 end, [2])
4
Link to this function

apply(module, function_name, args)

View Source

Specs

apply(module(), function_name :: atom(), [any()]) :: any()

Invokes the given function from module with the list of arguments args.

apply/3 is used to invoke functions where the module, function name or arguments are defined dynamically at runtime. For this reason, you can't invoke macros using apply/3, only functions.

If the number of arguments and the function name are known at compile time, prefer module.function(arg_1, arg_2, ..., arg_n) as it is clearer than apply(module, :function, [arg_1, arg_2, ..., arg_n]).

Inlined by the compiler.

Examples

iex> apply(Enum, :reverse, [[1, 2, 3]])
[3, 2, 1]