iex(16)> defmodule A do def _fib(n, %{ ^n => result }), do: result end** 
(MatchError) no match of right hand side value: :error

Notice this is a compilation error.

Some background. This is part of a Fibonacci function that uses a cache 
(the second parameter). If I get a cache hit, I want to return the 
corresponding value.

The concept works outside the context of a function parameter list:

iex(16)> cache = %{ 0 => 0, 10 => 55 }%{0 => 0, 10 => 55}
iex(17)> n = 10; %{ ^n => result } = cache; result55

Elixir 1.5.0-dev (3094471)

If it's a bug, I'll submit it.

Cheers

Dave
​

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/6c948795-eafd-4a05-af81-857cf470daa5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to