Skip to content

Instantly share code, notes, and snippets.

@krainboltgreene
Last active May 6, 2020 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krainboltgreene/a5644d1d69cf2b24c983e9d5a9a559a7 to your computer and use it in GitHub Desktop.
Save krainboltgreene/a5644d1d69cf2b24c983e9d5a9a559a7 to your computer and use it in GitHub Desktop.
defmodule A do
# What you can write in Elixir
@spec a(String.t()) :: integer
def a(b) when is_bitstring(b) do
if b == "hello" do
1
else
2
end
end
@spec a(any) :: false
def a(_), do: false
end
# What Erlang see
@spec a(String.t() | any) :: integer | false
# Note, that what this suggests is that somehow a() an be given a string and
# return false. This will never and can never happen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment