Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Write a function that uses matching to selectively print “success” or “error: message” given input of the form {error, Message} or success.
-module(print_err_success).
-export([print/1]).
%Assignment: Write a function that uses matching to selectively print “success” or “error: message” given input of the form {error, Message} or success.
%Simple return Success String.
print(success) -> "Success";
%Error message. The '++' concatenates the two strings.
print({error, Message}) -> "Error: " ++ Message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.