Skip to content

Instantly share code, notes, and snippets.

@maxlapshin
Created March 24, 2015 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxlapshin/a95d8a27ce93221d883a to your computer and use it in GitHub Desktop.
Save maxlapshin/a95d8a27ce93221d883a to your computer and use it in GitHub Desktop.
-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