Skip to content

Instantly share code, notes, and snippets.

@abp
Forked from alandipert/reinvoke.cljs
Created April 9, 2012 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abp/2346866 to your computer and use it in GitHub Desktop.
Save abp/2346866 to your computer and use it in GitHub Desktop.
It's sweet that 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