[erlang-questions] Syntax for accessing a single value of a map

Donald Steven <>
Sat Jan 26 22:26:29 CET 2019


Thanks Brian, that's very helpful.

Best,

Don

On 1/26/2019 4.20 PM, Bryan Paxton wrote:
>   Hi Donald,
>
> This part of the syntax has not been implemented yet. Currently you need
> to use maps:get/2 or maps:get/3 (http://erlang.org/doc/man/maps.html#get-2)
>
>
> Example:
>
> Eshell V10.2.1  (abort with ^G)
> 1> M = #{foo => bar}.
> #{foo => bar}
> 2> maps:get(foo, M).
> bar
> 3> maps:get(bar, M, undefined).
> undefined
> 4>
>
>
> Cheers
>
> --
>
> Bryan
>
>
> On 1/26/19 2:04 PM, Donald Steven wrote:
>> The book "Learn You Some..." notes that the syntax M#{K} may not work
>> and indeed it results in an error when I tried to use it.  What is the
>> correct syntax?
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list