Corner.Assign (corner v0.1.2)
Define the macro assing/2
and to/2-3
make the code more clean.
example
Example
require Corner.Assign, as: Assign
function_return_tag_value()
|> Assign.to({:ok, v}, do: v + 1)
|> go_on_work_with_v_plus_one()
Or if you more like import
:
import Corner.Assign, only: [assign: 2]
function_return_tag_value()
|> assign(to: {:ok, v}, do: v + 1)
|> go_on_work_with_v_plus_one()
Link to this section Summary
Functions
Assign value
to the variable(s) in the pattern
.
Same as assign(value, to: pattern)
.
Same as assgin(value, to: pattern, do: block)
.
Link to this section Functions
Assign value
to the variable(s) in the pattern
.
The keyword
shold be [to: pattern]
or [to: pattern, do: expression]
.
If the keyword
is [to: pattern]
the value of this function is the value
.
If the keyword
have the option :do
, the value of the expression
will
be return.
Same as assign(value, to: pattern)
.
Same as assgin(value, to: pattern, do: block)
.