Created
July 19, 2019 04:16
-
-
Save brandonbloom/30edfdb1543bea9e205f50dde3dd07b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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