Here's a fleshed-out version that tests for any type of primitive:
(definterface IPrimitiveTester
(getType [^int x])
(getType [^long x])
(getType [^float x])
(getType [^double x])
(getType [^byte x])
(getType [^short x])
(getType [^char x])
(getType [^boolean x])
(getType [^Objec
Hi,
Am 18.09.2011 um 18:54 schrieb Brent Millare:
> That's cool. Good to know.
And another (concluding?) remark: Calling .getClass on a primitive doesn't
work, since primitives are no objects. So the integer is boxed again to … Long.
Hence you get the same result as with type or class.
Sincer
That's cool. Good to know.
Thanks,
Brent
On Sep 18, 12:25 pm, David Nolen wrote:
> No need to leave Clojure to see what's going on:
>
> (definterface IntTest
> (intTest [^int n])
> (intTest [^long n]))
>
> (deftype IntTester []
> IntTest
> (intTest [this ^int n] (println "A primitive int
No need to leave Clojure to see what's going on:
(definterface IntTest
(intTest [^int n])
(intTest [^long n]))
(deftype IntTester []
IntTest
(intTest [this ^int n] (println "A primitive int!"))
(intTest [this ^long n] (println "A primitive long!")))
(comment
(.intTest (IntTester.) 1)
Hi,
Am 18.09.2011 um 15:36 schrieb Brent Millare:
> Even if I use what type does underneath and call .getClass myself (so
> there is no boxing), I still get type long. Also to be more specific,
> I am interested in the primitive int, not java.lang.Integer.
You could do a hardcore try and use a s
Hi Meikel,
Even if I use what type does underneath and call .getClass myself (so
there is no boxing), I still get type long. Also to be more specific,
I am interested in the primitive int, not java.lang.Integer.
Best,
Brent
On Sep 18, 4:10 am, Meikel Brandmeyer wrote:
> Hi,
>
> Am 18.09.2011 um
Hi,
Am 18.09.2011 um 07:31 schrieb Brent Millare:
> Is it possible to cast a number into an int in 1.3.0-RC0?
>
> ;user=> (type 0)
> java.lang.Long
> ;user=> (type (int 0))
> java.lang.Long
int does cast to an integer for direct java interop. type is function so the
integer will be boxed. 1.3