On Sep 8, 11:52 am, chris idr <[EMAIL PROTECTED]> wrote: > rhino is calling my function > String getValue() > > which i return the string value from what ever it called it on. > the problem is that if the value is 1.5 or 0.0 then rhino treats it as a > string even though it needs to be treated as a number for the javascript > that is in use. > > is there anything i can do about this?
If your function returns: int: rhino will convert it to a Javascript number String: rhino will convert it to a Javascript string I don't think there is anything surprising about that. call parseInt() on it from your Javascript code if you need to convert to an integer. A string of "1" is fundamentally different than an integer 1 except for a few oddball languages like Perl and Tcl. If your function returns Object then things get more surprising... by default an integer will be wrapped as an object rather than converted to a number and you have to call obj.intValue() to get an integer. This can be adjusted from Java driver code using Context().getWrapFactory().setJavaPrimitiveWrap(). (In regards to your other mail, note that java.lang.Integer(1) + java.lang.Integer(2) gives "11" rather than 2 or java.lang.Integer(2)) - Owen _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
