Skip to content

Instantly share code, notes, and snippets.

@eiri
Created May 24, 2016 13:16
Show Gist options
  • Save eiri/df49fb11b1fcc9c1c745b8d2ee6d7f70 to your computer and use it in GitHub Desktop.
Save eiri/df49fb11b1fcc9c1c745b8d2ee6d7f70 to your computer and use it in GitHub Desktop.
Use io_lib_pretty to pretty print records
-module(demo).
-export([print/0]).
-record(magic_record, {
alpha = 1,
beta = b,
gamma = [x, y, z],
psy,
omega = "done"
}).
-define(pp(Rec, Name), io_lib_pretty:print(Rec, fun(_, _) -> record_info(fields, Name) end)).
print() ->
R = #magic_record{},
io:format("~s~n", [?pp(R, magic_record)]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment