Skip to content

Instantly share code, notes, and snippets.

@fogus
Created August 26, 2010 13:12
Show Gist options
  • Save fogus/551351 to your computer and use it in GitHub Desktop.
Save fogus/551351 to your computer and use it in GitHub Desktop.
(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