Skip to content

Instantly share code, notes, and snippets.

@jlouis
Created January 21, 2011 17:34
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 jlouis/790047 to your computer and use it in GitHub Desktop.
Save jlouis/790047 to your computer and use it in GitHub Desktop.
Generating a proplist from a record
-module(foo).
-compile(export_all).
-record(foo, {a,b,c}).
foo_to_proplist(#foo{} = F) ->
[{K, element(I, F)} ||
{K, I} <- lists:zip(record_info(fields, foo),
lists:seq(2,record_info(size, foo)))].
@shadid
Copy link

shadid commented Oct 11, 2011

nice!

@jlouis
Copy link
Author

jlouis commented Oct 11, 2011

It is somewhat of a quick hack to do it. I'd recommend that you be a bit wary of using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment