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

empro2@REDACTED empro2@REDACTED
Sun Jan 27 15:22:01 CET 2019


What about matching?

M = #{1 => 2}.
#{1 => 2}
143> #{1 := V} = M.
#{1 => 2}
144> V.
2

What about reading the manual? :-)

<http://erlang.org/doc/reference_manual/expressions.html#map_expressions>

Similarly:

%% Instead of Val = Record#rec_name.some_field.
#rec_name{some_field = Val} = Record.

Lest Erlang turns into Java ;-)

Michael

--

You do not live in your environment,
you are part of it.














More information about the erlang-questions mailing list