Hi, there. I learned about using 'include' to implement a Java interface in JRuby. However, I can't determine what effect it really has. I tried creating a Runnable implementation without using the include, and, to my surprise, it ran without errors. Why? The code is at https://gist.github.com/3383582. Thanks, Keith
on 2012-08-18 02:19
on 2012-08-18 02:30
When an argument to a Java method takes an interface, you can pass
*any* object. We will create a hidden implementation of the interface
behind the scenes and pass that; it will proxy all calls to your
object.
For example:
system ~/projects/jruby $ javap Runnables
Compiled from "runnables.mirah"
public class Runnables {
public static java.lang.Runnable run(java.lang.Runnable,
java.lang.Runnable, java.lang.Runnable);
public Runnables();
}
system ~/projects/jruby $ jruby -rjava -e "Java::Runnables.run(->{puts
'hi'}, ->{puts 'from'}, ->{puts 'JRuby'})"
hi
from
JRuby
Easy-peasy!
- Charlie
on 2012-08-18 20:42
I want to learn ruby on rails using my laptop which run windows XP. please any one help me which software's i must download for XP. specify the s/w name with version and any step by step guide line is on the net that help me to install, working/programming with ruby on rails and can able to develop any web applications in future. Regards
on 2012-08-18 21:00
Start with the RailsInstaller - http://railsinstaller.org/. Note that it installs MRI, not JRuby. You will have to install JRuby from http://jruby.org/
on 2012-08-18 21:04
I want to learn ruby on rails using my laptop which run windows XP. please any one help me which software's i must download for XP. specify the s/w name with version and any step by step guide line is on the net that help me to install, working/programming with ruby on rails and can able to develop any web applications in future. Regards
on 2012-08-18 21:35
Charlie - Thanks for responding. So are you saying that using 'include' for an interface implementation is not necessary? Does it provide any functionality at all? When would one use it? Thanks, Keith
on 2012-08-18 22:46
Using include will perform a bit better because we can immediately see the interfaces the object supports and we also can make the Java object representing the Ruby object *actually* implement those interfaces rather than generating/instantiating a separate object attached to the Ruby object. I believe dispatch from Java through the interface is faster using a class + include than the "magic" form too. - Charlie (mobile)
on 2012-08-20 14:43
The easy way may be a rack vm that contains a full installation of rails ready to work El 18/08/2012 21:05, "SAYDUL K." <lists@ruby-forum.com> escribi:
on 2012-08-20 15:45
Like this http://bitnami.org/stack/rubystack El 20/08/2012 14:43, "Manuel Ramos" <manuelramoscaro@gmail.com> escribi:
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.