Skip to content

Instantly share code, notes, and snippets.

@spoon16
Last active December 17, 2015 06:19
Show Gist options
  • Save spoon16/5564170 to your computer and use it in GitHub Desktop.
Save spoon16/5564170 to your computer and use it in GitHub Desktop.

Revisions

  1. Eric Schoonover revised this gist May 13, 2013. 1 changed file with 10 additions and 8 deletions.
    18 changes: 10 additions & 8 deletions defprotocol_ArityException.clj
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    (defprotocol Pizza
    (slice [this]))

    (defn slice
    []
    (slice "hello world"))
    ([]
    (slice "hello world"))
    ([v]
    (-slice v)))

    (defprotocol Pizza
    (-slice [this]))

    (extend-type String
    Pizza
    (slice [this] (do this)))
    (-slice [this] (do this)))

    (slice "works") ;; Works Fine
    (slice) ;; ArityException
    (slice "works") ;; works
    (slice) ;; hello world
  2. Eric Schoonover created this gist May 12, 2013.
    13 changes: 13 additions & 0 deletions defprotocol_ArityException.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    (defprotocol Pizza
    (slice [this]))

    (defn slice
    []
    (slice "hello world"))

    (extend-type String
    Pizza
    (slice [this] (do this)))

    (slice "works") ;; Works Fine
    (slice) ;; ArityException