Hello.
At times I “wish” to more easily port java code straight over to jruby.
Ex:
BorderLayout.SOUTH
Could I make a feature request that for each public static constant, a
getter method be created or faked? I’d be happy to create a JIRA for it
if so desired.
Thanks!
-roger-
In Ruby, aren’t constants in classes defined by the :: separator, such
that this would be BorderLayout::SOUTH instead? I’d be wary of doing
this,
since it could be a very slippery slope of adding Java semantics over to
Ruby, where you could probably go on for quite a while and make JRuby
look
like GroovyRuby instead…
-Nick K.
While I’m at it…
This conversion might be nice:
cannot convert instance of class org.jruby.RubyHash to class
java.util.Dictionary (RubyHash -> Hashtable)
Cheers!
-roger-
Yeah, I have to say that I strongly believe that BorderLayout::SOUTH
is the right Ruby abstraction. The “.” character in Ruby means an
invocation, and that’s clearly not happening here.
Ruby syntax is not Java syntax
I think that might be going a bit far; Hashtable and Dictionary are
specific concrete classes; automatically converting from a Ruby Hash
into one of those types would be very peculiar.
We could probably make Ruby Hash automatically pass as Map, since the
implementation of the Map interface’s methods already do conversions
on the way in and out. The other direction is already largely there;
Map duck types as Hash and in some cases promotes to a full Hash.
It might be possible for someone to do their own hook via
const_missing to add a SOUTH method (have not really thought where the
magic for that should be put, but it should be possible) during Java
class import.
-Tom
On Wed, Jul 20, 2011 at 8:33 AM, Charles Oliver N.
[email protected] wrote:
this would be BorderLayout::SOUTH instead? I’d be wary of doing this, since
Ex:
Posted via http://www.ruby-forum.com/.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
–
blog: http://blog.enebo.com twitter: tom_enebo
mail: [email protected]