Re: Convert an array of strings from JRuby -> Java?

(Source:
http://wiki.jruby.org/wiki/index.php?title=JRuby_Cookbook&printable=yes)
Creating Java Arrays
You can convert ruby arrays to java arrays very simply: [1,2,3].to_java
=> makes an object array
[1,2,3].to_java :byte => makes a byte array
[1,2,3].to_java :String => makes a String array

Hths,
James

----- Original Message ----
From: Martin C. Martin [email protected]
To: [email protected]
Sent: Tuesday, August 26, 2008 11:17:37 AM
Subject: [jruby-user] 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

Thanks! It’s a shame the cookbook isn’t linked from the main JRuby.org
page under “documentation.” It seems quite general.

Best,
Martin

James Chang wrote:

[1,2,3].to_java :byte => makes a byte array
Subject: [jruby-user] Convert an array of strings from JRuby -> Java?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

It’s an open wiki, so if you think it should have a link on the front
page please add one.

Martin C. Martin wrote:

http://wiki.jruby.org/wiki/index.php?title=JRuby_Cookbook&printable=yes)


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

www.jruby.org is not really the main page for JRuby, because we really
don’t like Confluence. Use wiki.jruby.org (and yes, we’ve debated moving
www.jruby.org to point at the wiki…)

  • Charlie

Martin C. Martin wrote:

Thanks! But when I click on the “Edit” link on www.jruby.org, I get:

http://docs.codehaus.org/pages/editpage.action?spaceKey=JRUBY&title=Home

You cannot view this page due to inherited restrictions


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Thanks! But when I click on the “Edit” link on www.jruby.org, I get:

http://docs.codehaus.org/pages/editpage.action?spaceKey=JRUBY&title=Home

You cannot view this page due to inherited restrictions

Best,
Martin

Charles Oliver N. wrote:

James Chang wrote:

[1,2,3].to_java => makes an object array
Sent: Tuesday, August 26, 2008 11:17:37 AM
Martin
To unsubscribe from this list, please visit:


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs