What error is it giving?

If obj.getShape actually is returning an object with a getRadius method, the code should work as written. If obj.getShape doesn't return an object with a getRadius method, it will end up calling the method_missing method, which by default throws an error. I think, anyway...

If you're trying to invoke the Java code from ruby, remember that Jruby translates to ruby-like method names, so you might try invoking those. The old names should still work, though. See http://wiki.jruby.org/wiki/Calling_Java_from_JRuby#Alternative_Names_and_Beans_Convention for more details

tonyaim83 wrote:
Hi Java code

 Shape s1= obj.getShape();
 s1.draw();
Circle c1 = (Circle)obj.getShape();
  c1.getRadius();

It's equivalent ruby code

   s1 = obj.getShape
   s1.draw
c1 = obj.getShape
   c1.getRadius
Now here i cannot use the type cast as i have used in java so not able to
invoke the methods of class circle. How to invoke it in ruby.? The code in
bold is giving error.



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to