On Wednesday 16 May 2007 1:05:29 pm Skeptic 2000 wrote:

> doesn't know the exact type... so I use the javaObjectValue method to 

Value has a type() method which tells you what kind of Value you've got. 
javaObjectValue() won't create an object -- it will only return an exusting 
object, if there is one (for resolved values, only for types RU.STRING, 
RU.SYMBOL, RU.JAVA_OBJECT.)

>
> Second Problem : A second UserFunction return a integer value by doing :
> int x = ... ;
> return new Value(x);

My first reaction was that the Value constructor that takes only an int isn't 
public -- have you modified the source? You should be using the two-argument 
one that lets you specify a type. But now, on re-reading, I see what's 
probably happening: *autoboxing* in Java 5 and up. You're passing only an int 
to the Value constructor, and there *is* no constructor that takes only an 
int. There is one that takes only an Object, though, so Java is helpfully 
converting your int to an Integer, and then Jess is creating a Value of type 
JAVA_OBJECT. Grrr. 

Although Java 5 blurred the distinction between int and Integer, Jess still 
treats them as distinct types. You should be using 

return new Value(x, RU.INTEGER);

and then everything should work fine.

---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550                 http://www.jessrules.com

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to