In Clojure, Those Parenthesis Really Matter

Posted in the “I hope no-one else has to go through this” category in the hope that Google surfaces this for some other poor soul.

Picture a rather trivial split function:

(defn split [str delimiter]
  ((seq (.split str delimiter))))

Which helpfully spits out:

java.lang.ClassCastException: clojure.lang.ArraySeq cannot be cast to clojure.lang.IFn

The issue here is the additional set of parentheses – a hang-over from a previous edit. Removing this fixed the trouble. These parentheses were causing Clojure to expect a function call…

No Trackbacks

You can leave a trackback using this URL: http://www.magpiebrain.com/2010/06/13/in-clojure-those-parenthesis-really-matter/trackback/

One Comment

  1. Thanks for the tip. Re the title: If they’re plural, then they’re parenthesEs.

    Posted June 17, 2010 at 4:36 am | Permalink

Post a Comment

Your email is never shared. Required fields are marked *

*
*