Created
May 24, 2016 13:16
-
-
Save eiri/df49fb11b1fcc9c1c745b8d2ee6d7f70 to your computer and use it in GitHub Desktop.
Use io_lib_pretty to pretty print records
This file contains hidden or 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
-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