On Thu, Nov 27, 2008 at 9:21 PM, Chouser <[EMAIL PROTECTED]> wrote:
>
> On Thu, Nov 27, 2008 at 2:12 PM, Kei Suzuki <[EMAIL PROTECTED]> wrote:
>>
>> Any formatted print method calls like below throw
>> java.lang.ClassCastException at clojure.lang.Compiler.eval.
>>
>> (.printf System/out "%d" 1)
>> (. System/out (printf "%d" 1))
>> (.format System/err java.util.Locale/US "%s" "error")
>> (. System/out format nil "%s" "hello, world!\n")
>>
>> Am I missing something? Is it necessary to add hints that help casting
>> variable args?
>
> All those methods take Java variadic arguments, which generally means
> you need build the array the method is expecting.  Fortunately, in the
> cases you list you can just use the Clojure function 'format' which
> does it for you:
>
> (.println System/out (format "%d" 1))

or (if you're not trying to send stuff to stderr or something):

user=> (printf "%d" 1)
1nil
user=> (printf "%s" "hello, world!\n")
hello, world!
nil
user=>

-- 
Michael Wood <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to