[erlang-questions] function clauses with maps (18.3)

Luis Azedo luis.azedo@REDACTED
Wed Mar 30 22:59:44 CEST 2016


Thanks for the reply.

so in the future in should work, right ? do you know which version/release
we should wait before testing this ?

Thanks


On Wed, Mar 30, 2016 at 9:54 PM, Björn-Egil Dahlberg <
wallentin.dahlberg@REDACTED> wrote:

> This is a current limitation with maps and bitsyntax. Variables has to be
> bound before being used as an expression in a pattern.
>
> 2016-03-30 22:01 GMT+02:00 Luis Azedo <luis.azedo@REDACTED>:
>
>> Hi,
>>
>> this doesn't compile in 18.3. is it supposed to work with the maps spec ?
>> maybe in a later release ?
>>
>> -spec my_match(atom(), atom(), map()) -> any().
>> my_match(Classification, CarType, #{my_key := #{ Classification := #{
>> <<"cars">> := #{ CarType := Map}}}}) ->
>> ....
>> variable 'Classification' is unbound
>> variable 'CarType' is unbound
>>
>>
>> this works but we're not taking advantage of function clauses.
>>
>> my_match(Classification, CarType, M ) ->
>>     #{my_key := #{ Classification := #{ <<"cars">> := #{ CarType :=
>> Map}}}} = M,
>>     Map.
>> ....
>>
>> TIA
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160330/4c710cdb/attachment.htm>


More information about the erlang-questions mailing list