Skip to content

Instantly share code, notes, and snippets.

@brandonbloom
Created July 19, 2019 04:16
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 brandonbloom/30edfdb1543bea9e205f50dde3dd07b2 to your computer and use it in GitHub Desktop.
Save brandonbloom/30edfdb1543bea9e205f50dde3dd07b2 to your computer and use it in GitHub Desktop.
(ns hr)
(defprotocol Employee
(fire [this]))
(ns war)
(defprotocol Missile
(fire [this]))
(ns hybrid
(:require [hr]
[war :refer [fire]]))
(deftype Hybrid [])
(extend-type Hybrid
hr/Employee
(fire [this] "employee")
war/Missile
(fire [this] "missile"))
(def inst (Hybrid.))
(prn (hr/fire inst))
(prn (war/fire inst))
(prn (fire inst)) ; disamibiguated by require
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment