logo       

Re: Auto type conversion: msg#00077

lang.groovy.user

Subject: Re: Auto type conversion

Robert,

Thanks! You are absolutely right. I should have call Math.max not max.

Thanks again

Pascal

On Tue, 2004-11-16 at 07:38, Robert McIntosh wrote:
>
>
> It appears you have to use the class for the static, unlike 1.5's static
> imports:
>
> print Math.max(0, qoh)
>
> should work.
>
> The message you were seeing was a little confusing, it was actually saying
> that it could not find a method called max with two Integer args on your
> script, not on Math.
>
> - Robert
>
>
>
> Tuesday, November 16, 2004 9:05 AM
> To: user-i9PBDF1N6cxnkHa44VUL00B+6BGkLq7r@xxxxxxxxxxxxxxxx
> cc:
> From: Pascal DeMilly <list.groovy-MAs0IwSbNVGU+1/U8MakDg@xxxxxxxxxxxxxxxx>
> Subject: [groovy-user] Auto type conversion
>
>
>
> I am writing a small script that use the java.Math.max method. The
> problem I am having is that groovy insists on transforming my int to
> Integer. Since max doesn't have a prototype for (Integer, Integer)
> groovy issues an Exception. How can I force groovy to pass an (int, int)
> to max
>
> import java.Math.max;
>
> <snip>
>
> mydb.eachRow ("SELECT * from Items) {
> int qoh = it.QtyOnHand.intValue()
> print max(0, qoh) // Exception
> }
>
> TIA
>
> Pascal
>




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise