Skip to content

Instantly share code, notes, and snippets.

@proudlygeek
Forked from alandipert/reinvoke.cljs
Created April 9, 2012 21:57
Show Gist options
  • Save proudlygeek/2346843 to your computer and use it in GitHub Desktop.
Save proudlygeek/2346843 to your computer and use it in GitHub Desktop.
It's sweet IFn is a protocol in ClojureScript
(extend-type js/RegExp
cljs.core.IFn
(-invoke ([this s] (re-matches this s))))
(#"foo.*" "foobar") ;=> "foobar"
(#"zoo.*" "foobar") ;=> nil
(filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment