Skip to content

Instantly share code, notes, and snippets.

@masteinhauser
Last active August 29, 2015 14:05
Show Gist options
  • Save masteinhauser/708e1df865911662815a to your computer and use it in GitHub Desktop.
Save masteinhauser/708e1df865911662815a to your computer and use it in GitHub Desktop.
Elixir: Match two fields of a struct against each other in a function definition
def foo(%State{attempted_address} = address, bar)) when address not nil do
# a thing, do it here
end
def foo(%State{address} = address, bar)) when address not nil do
# a thing, do it here
end
@CaptChrisD
Copy link

I don't think

%State{address} = address

is valid... I get a compile error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment