Skip to content

Instantly share code, notes, and snippets.

@Gustav-Simonsson
Created December 20, 2011 13:06
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/1501514 to your computer and use it in GitHub Desktop.
Save Gustav-Simonsson/1501514 to your computer and use it in GitHub Desktop.
proplist_to_record
-define(proplist_to_record(Record),
fun(PropList) ->
[_Tag | Defaults] = tuple_to_list(#Record{}),
Fields = record_info(fields, Record),
list_to_tuple([Record | [proplists:get_value(F, PropList, D)
|| {F, D} <- lists:zip(Fields, Defaults)]])
end).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment