|
Re: Auto type conversion: msg#00078lang.groovy.user
My pleasure. As soon as I saw James' first response I thought it should have worked, so I tried it myself and I recognized the error, which I've had many times myself. Better error reporting is one of the biggest requests :-) - Robert Tuesday, November 16, 2004 10:00 AM To: user-i9PBDF1N6cxnkHa44VUL00B+6BGkLq7r@xxxxxxxxxxxxxxxx cc: From: Pascal DeMilly <list.groovy-MAs0IwSbNVGU+1/U8MakDg@xxxxxxxxxxxxxxxx> Subject: Re: [groovy-user] 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> |
|---|---|---|
| Previous by Date: | Re: Auto type conversion, Pascal DeMilly |
|---|---|
| Next by Date: | Re: Auto type conversion, jastrachan-ee4meeAH724 |
| Previous by Thread: | Re: Auto type conversion, Atif Shahab |
| Next by Thread: | Re: Auto type conversion, jastrachan-ee4meeAH724 |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | Mail Home | sitemap | FAQ | advertise |