Search code examples
clojureclasscastexception

Not sure why i'm getting a classCastException


I am trying to sort the max in lists using this recursion. Unsure why I am getting a class cast exception when trying to call maxOf2.

Code


Solution

  • You have many spacing errors, which is probably the problem. Also, too many extra parenthesis like (maxOf2(firstVal ... should probably be:

    (maxOf2 firstVal (listMax (rest aList)))   ; ***** notice spacing! *****
    

    Please also consult this list of documentation for more resources.