ctrl do
{:ok, state} <- init() # Classic `with` clause
%{id: id, opts: opts} = state # Any expression
:ok <- register(id)
:f_repo | {:ok, repo} <- Keyword.fetch(opts, :repo) # Tagged match
:f_user | {:ok, user} <- Keyword.fetch(opts, :user) # Different tagged match
{:ok, do_something(id, repo, user)}
else
{:error, _} = err -> err # Errors with info
:f_repo | :error -> {:error, :no_repo_option} # Errors on :repo only
:f_user | :error -> {:error, :user_not_set} # Errors on :user only
endwith all: {:ok, users} <- all: cashed_users()
best: {:ok, user} <- best: get_best_user(users)
do state
else all: {:error, msg} -> dostuff
best: {:error, msg} -> dostuff
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/3c8eca18-fc6c-4317-a81b-5b83f4978279%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/cc528045-5c18-44fc-99cc-71f787db0632%40googlegroups.com.
I believe this construct may promote complex code.
Why do we need this? Elixir has excellent patten matching support that is lightyears ahead of the C class of languages. Better than a more flexible with statement is to split the code into smaller chunks.
Sorry, my humble opinion. To be fair, I did not go into great depths to learn how the code works, and might have missed something.
I believe the use of '|' is new?
Tallak