Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-module(map_test1).
-export([main/0]).
-record (r1, {map_data, a = 0}).
main() ->
R1 = #r1{map_data = #{count => 1}},
io:format("Created: ~p~n", [R1]),
R2 = modify(R1),
io:format("Modified: ~p~n", [R2]).
modify(#r1{map_data = #{count := Cnt} = M}=R1) ->
NewM = M#{count := Cnt + 1},
R1#r1{map_data = NewM}.
-module(map_test2).
-export([main/0]).
-record (r1, {map_data, a = 0}).
main() ->
R1 = #r1{map_data = #{count => 1}},
io:format("Created: ~p~n", [R1]),
R2 = modify(R1),
io:format("Modified: ~p~n", [R2]).
modify(#r1{map_data = #{count := Cnt} = M}=R1) ->
NewM = M#{count := Cnt + 1},
R1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.