Why I still allowed to do this?
@spec url_hash(String.t) :: String.t
def url_hash(url) do
url = String.replace(url, ~r/\s/, "")
Base.encode16(:crypto.hash(:md5, url), case: :lower)
end
Instead of, what I think a proper functional programming paradigm?
@spec url_hash2(String.t) :: String.t
def url_hash2(url) do
url_copy = String.replace(url, ~r/\s/, "")
Base.encode16(:crypto.hash(:md5, url_copy), case: :lower)
end
As you can see, I'm modifying parameter value inside the function body.