1
votes

I have been reading some Erlang function and came across something I do not understand. I have read the online manual (http://erlang.org/doc) but still don't understand.

In the line below, how is one supposed to read each of the variables?

#{Var1 := Var2} = Var3

The code I came across is this:

#{Namekey := Value} = FullNameRel

Thank you so much.

1

1 Answers

4
votes

The syntax is used for pattern matching in key value associations in maps, see maps.

For example,

mymap()->
    Key = 'Key',
    Map = #{Key => 'Old value', 'Key2' => 'Other value'},
    #{Key := Value} = Map,
    Value.  % returns 'Old value'