I'am struggling with records in one of my modules.
I defined on top of my code a record as:
-record(user, {pid,
name,
nick}).
in few words each user is going to be represented as process with its own pid and other fields.
Later on in the module I am doing the following:
Pid = UserPid,
GetUser = fun(X) ->
if X#user.pid =:= Pid -> true;
X#user.pid=/= Pid -> false
end
end,
User = lists:filter(GetUser, Users),
io:format("User pid is ~p~n",[User#user.pid]).
Running this code I get:
** exception error: {badrecord,user}
But if I do:
io:format("User ~p~n",[User]).
It prints
User [{user,<0.33.0>,name1,nick1}]
Can anyone point out what i am missing?
Thanks
[U || U <- Users, U#user.pid =:= P]
. – Biogen