Created
December 20, 2011 13:06
-
-
Save Gustav-Simonsson/1501514 to your computer and use it in GitHub Desktop.
proplist_to_record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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