Created
April 5, 2017 11:38
-
-
Save iain17/396346f814643964c58eed617a5df018 to your computer and use it in GitHub Desktop.
Write a function that uses matching to selectively print “success” or “error: message” given input of the form {error, Message} or success.
This file contains 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(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