Created
September 18, 2017 15:36
-
-
Save ohammersmith/b0b6d569c4d4504e5a983a224cc4d7e9 to your computer and use it in GitHub Desktop.
User struct for get_in
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 User do | |
defstruct [:age] | |
def fetch(term, key) do | |
Map.fetch(term, key) | |
end | |
def get(term, key, default) do | |
Map.get(term, key, default) | |
end | |
def get_and_updated(data, key, function) do | |
Map.get_and_update(data, key, function) | |
end | |
def pop(data, key) do | |
Map.pop(data, key) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment