The problem I am trying to solve is as follows:
Write an Erlang function named print_message that takes no arguments. The function should wait to receive a message. When the message is received (it can be any Erlang term), print the message using io: format(). If 42 seconds pass without receiving a message, print a message that says “Too late.”.
The code that I wrote for the problem is down below:
print_message() ->
receive
X -> io:format("~p~n",[X])
after 42000 ->
io:format("Too late ~n")
end.
In my question, it says 'it can be any Erlang term'. Does using X in my code fulfill that requirement? Or do I need to use the Erlang built in function of any() as stated in the below reference manual: https://erlang.org/doc/reference_manual/typespec.html?