Skip to content

Instantly share code, notes, and snippets.

@Gustav-Simonsson
Created October 8, 2011 20:21
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 Gustav-Simonsson/1272824 to your computer and use it in GitHub Desktop.
Save Gustav-Simonsson/1272824 to your computer and use it in GitHub Desktop.
-module(records).
-compile(export_all).
-record(foo, {bar = "baz"}).
-define(make_record_to_list(Record),
fun(Val = #Record{}) ->
Fields = record_info(fields, Record),
[_Tag| Values] = tuple_to_list(Val),
lists:zip(Fields, Values)
end
).
test() ->
Foo = #foo{bar = "qux"},
Fun = ?make_record_to_list(foo),
Fun(Foo).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment