I have following code:
Check#tab_info{login_errors = 0},
{ok, PID};
But i get warning when i try to compile it:
the result of the expression is ignored (suppress the warning by assigning the expression to the _ variable)
What's wrong? How can i fix it?
Thank you.
Well, the compiler is telling you exactly what's wrong :) You create a new #tab_info
record, but never bind it to any variable. The code is therefore meaningless and the compiler is telling you so. Changing the Check
variable (or more correctly, creating a new one) won't have any effect unless you return it. Check
is not a global variable, like it might be in imperative languages. Also, changing a variable you receive as an argument to a function, will not result in a change in how the caller sees the variable.
You want to bind the expression to some variable and then do something meaningful with it.
NewCheck = Check#tab_info{...}
{ok, Pid, NewCheck}
As a side note, if instead you did a function call and did not bind the return value to anything, the compiler would not complain as the function might have side-effects and this might be the reason you called the function in the first place.