Forum: JRuby Why Ruby Array does not get implicitly converted to Java Array?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sergio Oliveira (Guest)
on 2008-12-15 20:40
(Received via mailing list)
This looks non-sense to me.

public static void printList(List<String> list) {
    // print the list
}

public static void printArray(String[] list) {
    // print the array
}

From Ruby:

a = ["a", "b", "c"]

PrintUtils.printList(a); # Works fine!

PrintUtils.printArray(a); # Nasty error

PrintUtils.printArray(a.to_java); # Nasty error

PrintUtils.printArray(a.to_java(:String)); # Finally ok!

Why the hassle to implicitly convert a Ruby array to a Java array but no
hassle to convert a Ruby array to a java.util.List<String> ???

Just curious if this is by design (on purpose) or if it is something to
be
improved in the future (pending improvement).

Thanks,

-Sergio
This topic is locked and can not be replied to.