Convert an array of strings from JRuby -> Java?

Hi,

I’m using JRuby to call into some Java code, and the Java method takes a
String[]. In JRuby, I’ve got a (Ruby) array of (Ruby) strings. How do
I convert them? Ruby’s String class doesn’t seem to have a to_string
method.

Best,
Martin


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Martin C. Martin wrote:

Hi,

I’m using JRuby to call into some Java code, and the Java method takes a
String[]. In JRuby, I’ve got a (Ruby) array of (Ruby) strings. How do
I convert them? Ruby’s String class doesn’t seem to have a to_string
method.

str_ary.to_java :string should do it.

âž” jruby -rjava -e “p [‘foo’, ‘bar’].to_java :string”
[Ljava.lang.String;@9b688e

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email