From: Jim Menard Date: 2008-07-22T04:19:28+09:00 Subject: Re: Ruby/Java strings solved the Ruby way On Sun, Jul 20, 2008 at 1:36 PM, Charles Oliver Nutter wrote: [snip] > So I propose that instead of always decoding incoming Ruby String into a > Java String when calling a Java method, we introduce a new type--call it > JString for now--that represents a Java string. When you require in the Java > integration support, it would add to Ruby String a method to_jstring (or > to_String or hey, toString?). So for calls from Ruby to Java, we'd follow > Ruby coercion protocols and only accept either JString or objects that > coerce to JString. > > Likewise, coming from Java to Ruby, we wouldn't automatically coerce; we'd > return a JString object that implements to_str. You can then usually pass > that to String APIs, or just coerce it immediately and go on with your > business. Since this latter change would break some apps that expect Java > strings to always be coerced, it would be saved for the next major release > of JRuby and thoroughly discussed. This sounds like an excellent compromise. I vote for to_jstring because it looks most Ruby-esque. Jim -- Jim Menard, jimm@io.com, jim.menard@gmail.com http://www.io.com/~jimm/