I would like to call a java method with a single function from ruby as a Proc/block etc.how ;)

All of the examples on jruby.org give examples of how to call methods
on an objec. None appear from what i could find give an example of
calling an instance method on some onbject as if it were a block/proc
without eg a function. I hope i got that terminology right… any help
would be appreciated.

I’m not sure I understand the question. Can you give an example of what
you’re trying to do, using pure ruby?

Doh the lead question had a few words jumbled up, let me start again…

I would like to know how to pass an interface with a single method (aka
a
java function) to ruby so that it may be executed like a block or
function.

ScriptingContainer.put(“multiply”, new RubyBlock (){

public Object execute( Object…parameters ){
// ive intentionally left out param checking and simplified
conversions
etc.
return ((Number)parameters[ 0 ]).intValue() * ((Number)parameters[ 1
]).intValue();
}

} );

ScriptingContainer.runScriptlet(“multiply( 2, 3 )”); // 6.

tya

On Mon, Aug 1, 2011 at 1:46 AM, Michael C.
<[email protected]