Why Ruby Array does not get implicitly converted to Java Array?

This looks non-sense to me.

public static void printList(List 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 ???

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



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