Skip to content

Instantly share code, notes, and snippets.

@jdkealy
Created June 4, 2020 16:28
Show Gist options
  • Save jdkealy/f0923bcd4312c692e4fc41f5864636ce to your computer and use it in GitHub Desktop.
Save jdkealy/f0923bcd4312c692e4fc41f5864636ce to your computer and use it in GitHub Desktop.
(defn rect [wd ht] {:Shape ::rect :wd wd :ht ht})
(defn circle [radius] {:Shape ::circle :radius radius})
(defn square [wd ht ] {:Shape ::square :wd wd :ht ht})
(defmethod area :default [x] :oops)
(defmethod area ::rect [r]
(* (:wd r) (:ht r)))
(derive ::square ::rect)
(area (rect 10 10))
(area (square 10 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment