Last active
August 29, 2015 14:05
-
-
Save bradleyd/e4254c0e647dc7bb8371 to your computer and use it in GitHub Desktop.
Pattern matching on many parameters
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
defmodule Message do | |
defstruct to: nil, subject: nil, text: nil, html: nil, from: nil, bcc: nil | |
# this is the minimum needed to send an email | |
def new(%{to: to, subject: subject, text: text, from: from}) do | |
{:ok, %Message{to: to, subject: subject, text: text, from: from} } | |
end | |
def new(%{to: to, subject: subject, html: html, from: from}) do | |
{:ok, %Message{to: to, subject: subject, html: html, from: from} } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment