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


#1

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
be
improved in the future (pending improvement).

Thanks,

-Sergio