Nel codice seguente, Clojure (1.2) è la stampa il messaggio sbagliato:Clojure non cattura NumberFormatException
(try
(let [value "1,a"]
(map #(Integer/parseInt %) (.split value ",")))
(catch NumberFormatException _ (println "illegal argument")))
Questo dovrebbe stampare "argomento illegale", ma invece viene stampato un (1#<NumberFormatException java.lang.NumberFormatException: For input string: "a">
.
Cosa sto sbagliando?
Ciò è dovuto alla sequenza lenta restituita da map
? Come dovrebbe essere scritto?
Questo dovrebbe essere utile: http://groups.google.com/group/clojure/msg/f4ea5a9c38f4d991 – MayDaniel