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?
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
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.
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?
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
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.