[erlang-questions] Pattern match error in Maps

Avinash Dhumane nistrigunya@REDACTED
Tue May 17 08:56:15 CEST 2016


avinash@REDACTED:~/tws$ erl
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:2:2] [async-threads:10]
[hipe] [kernel-poll:false]

Eshell V7.3  (abort with ^G)
1> M = #{{a, 1} => 100, {a, 2} => 200, {a, 3} => 300}.
#{{a,1} => 100,{a,2} => 200,{a,3} => 300}
2>  lists:map(fun(N) -> #{{a, N} := V}= M, V div 10 end, lists:seq(1,3)).
* 1: illegal map key in pattern
3>

I can get it working with maps:get/2

But, I seem not to understand when and where may variables be used in the
pattern.

What am I  missing?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160517/1c9315be/attachment.htm>


More information about the erlang-questions mailing list