logo       

Re: [jruby-user] Creating Java arrays: msg#00153

lang.jruby.user

Subject: Re: [jruby-user] Creating Java arrays

require 'java'

arr = Array.new
arr << java.lang.String.new('one')
arr << java.lang.String.new('two')
arr << java.lang.String.new('three')

irb(main):023:0> arr.each do |a|
irb(main):024:1* puts a.class
irb(main):025:1> end
Class
Class
Class
=> [Java::JavaLang::String, Java::JavaLang::String, Java::JavaLang::String]
irb(main):026:0> arr.to_java.each do |a|
irb(main):027:1* puts a.class
irb(main):028:1> end
Java::JavaLang::Class
Java::JavaLang::Class
Java::JavaLang::Class

Something like that?

M


On Nov 18, 2007 12:58 AM, Scott Davies <scottd@xxxxxxxxx> wrote:
> Simple JRuby newbie question: how do you create a Java array of a
> particular Java type in JRuby? I haven't seen any mention of this in
> the docs I've managed to find, and trying to search over the mailing
> list archive on Codehaus currently makes the site barf ("application
> error").
>
> Thanks,
>
> -- Scott
>
> ---------------------------------------------------------------------
> 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




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise