Created
August 26, 2010 13:12
-
-
Save fogus/551351 to your computer and use it in GitHub Desktop.
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
(ns fogus | |
(:refer-clojure :exclude [or +])) | |
(defprotocol ReadOps | |
(+ [this rhs]) | |
(or [this rhs])) | |
(extend-type String | |
ReadOps | |
(+ [this rhs] | |
(clojure.core/+ (Integer/parseInt this) rhs)) | |
(or [this rhs] | |
(clojure.core/or (Boolean/getBoolean this) rhs))) | |
(+ "2" 40) | |
;=> 42 | |
(or "false" true) | |
;=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment