Created
March 19, 2018 17:49
-
-
Save ihorkatkov/d0913fbeb42be37e406da534199286cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Example do | |
defp plug_address_chunk(addr, nil), do: addr | |
defp plug_address_chunk(addr, key), when String.length(addr) > 0 and String.length(key) > 0 do: addr <> ", " <> city | |
defp plug_address_chunk(addr, key), do: addr <> city | |
def get_address() do | |
street = … | |
city = … | |
state = … | |
zip = … | |
addr = street || "" | |
result = addr | |
|> plug_address_chunk(city) | |
|> plug_address_chunk(state) | |
|> plug_address_chunk(zip) | |
case result do | |
"" -> "Unknown Location" | |
address -> address | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment