Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Untitled notebook

books/basics/protocols.livemd

Untitled notebook

Section

defprotocol Utility do
  @spec type(t) :: String.t()
  def type(value)
end
defimpl Utility, for: BitString do
  def type(_value), do: "string"
end

defimpl Utility, for: Integer do
  def type(_value), do: "integer"
end
Utility.type("string")

Utility.type(123)

Utility.type([])