Type coercion asymmetry

7 views
Skip to first unread message

Jeff Rose

unread,
Nov 25, 2008, 11:11:04 AM11/25/08
to clo...@googlegroups.com
It seems this is the best way to go currently:

user=> (Integer/parseInt "1234")
1234

but wouldn't it be nice if this worked:

user=> (str 123)
"123"
user=> (str 12.123)
"12.123"
user=> (int "123")
java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Character (NO_SOURCE_FILE:0)
user=> (float "12.123")
java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Number (NO_SOURCE_FILE:0)

-Jeff

Reply all
Reply to author
Forward
0 new messages