Welcome! Please see the About page for a little more info on how this works.
Observed behaviour
` (int "0") => java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
`
Expected behaviour (int "0") => java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer or IllegalArgumentException `
Comment made by: jafingerhut
If someone wants to improve the behavior of int in this case, they should also consider similar improvements to the error messages for unchecked-int, char, and unchecked-char.
Comment made by: michael-drogalis
Patch improved-int-char-casting-error-messages.diff on January 6, 2013.
Comment made by: alexmiller
{{int}} knows how to coerce numbers and chars to ints. It does not currently support Strings. It would be worthwhile to either add this behavior or make int's docstring more descriptive than just "Coerce to int".
string-coerce-to-int.diff September 4th, 2013 Fixes int and char casting error messages, and allows casting from String to int as Alex Miller suggested.
Notably, (map int (link: "1" "2" "3")) fails with "ClassCastException java.lang.String cannot be cast to java.lang.Character" using this patch. It emanates from RT.java from intCast(Object). So it looks like the Strings are losing their types when they're being mapped over. I would guess this is intentional?