Created
August 12, 2013 12:11
-
-
Save ihercowitz/5397fc60772f04d1d8ee to your computer and use it in GitHub Desktop.
A very simple polymorphic method in clojure
This file contains hidden or 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
| (defprotocol Hello (say [x])) | |
| (extend-protocol Hello | |
| String (say [x] (str "Hello String " x)) | |
| Long (say [x] (str "Hello Number " x))) | |
| ;usage | |
| (say "World") ;expected: "Hello String World" | |
| (say 42) ;expected: "Hello Number 42" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment