Skip to content

Instantly share code, notes, and snippets.

@pragdave
Last active December 17, 2015 12:19
Show Gist options
  • Save pragdave/5609055 to your computer and use it in GitHub Desktop.
Save pragdave/5609055 to your computer and use it in GitHub Desktop.
defprotocol WhizBang do
def specific(_)
def common(_)
end
defrecord Foo, name: "foo"
defrecord Bar, name: "bar"
defmodule Common do
def common(arg), do: IO.puts "Common.common: #{inspect arg}"
end
defimpl WhizBang, for: Foo do
defdelegate common(foo), to: Common
def specific(_foo), do: IO.puts "specific Foo"
end
defimpl WhizBang, for: Bar do
defdelegate common(bar), to: Common
def specific(_bar), do: IO.puts "specific Bar"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment