[Erlang-0012][OTHERS] key-value结构实现match_object
-module(record_match).
-compile(export_all).
-record(aaa, {a=1,b=0,c=c}).
record_match() ->
record_match2([#aaa.a, 1, #aaa.b, b]).
record_match2(KVList) ->
List = get_list(),
record_match3(KVList, List).
record_match3([], List) ->
List;
record_match3(_, []) ->
[];
record_match3([Key, Value|T], List) ->
NewList = [X || X <- List, element(Key, X) =:= Value],
record_match3(T, NewList).
get_list() ->
[#aaa{a=1}, #aaa{a=1, b=b}, #aaa{c=3}].