Skip to content

Instantly share code, notes, and snippets.

@iain17
Created April 5, 2017 11:38
Show Gist options
  • Save iain17/396346f814643964c58eed617a5df018 to your computer and use it in GitHub Desktop.
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.
-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