View Source ExUp (ExUp v0.1.0)
Documentation for ExUp.
Link to this section Summary
Functions
Defines a function or a deprecated function that delegates to mod. Depending on the Elixir version.
Link to this section Functions
Link to this macro
defup(elixir_since, mod, fun, args \\ [], list)
View Source (since 0.1.0) (macro)Defines a function or a deprecated function that delegates to mod. Depending on the Elixir version.
The first argument is the elixir version since this function is available.
The mod argument is the original elixir module where the function is implemented.
The fun argument is the original elixir function name.
args is a list of arguments that the generated function will accept.
body is the implementation older versions of elixir will use, it should do the same of the
original function.
examples
Examples
iex> defmodule Sample1 do
...> import ExUp
...> defup("1.0.0", List, :first, [list, default \\ nil]) do
...> case list do
...> [] -> default
...> [first | _] -> first
...> end
...> end
...> end
iex> Sample1.first([])
nil
iex> Sample1.first([1, 2])
1