-------- Original-Nachricht --------
> Datum: Wed, 14 Oct 2009 06:19:01 +0900
> Von: "Walton Hoops" <walton / vyper.hopto.org>
> An: ruby-talk / ruby-lang.org
> Betreff: Re: how to solve a special JRuby and Java syntax conflict?

> Axel Etzold wrote:
> > Dear Paul,
> > 
> > thank you for responding. However, I am not looking for a way of
> > dealing
> > with a Matrix as such ( there would be no need to use Java for it),
> > but I need to talk to a specific implementation of Matrix methods in
> > Java.
> > 
> > I can do that nicely in JRuby, since the latter is basically Ruby 1.8.6
> > implemented in Java (rather than in C), but I have this syntax issue:
> > 
> > I want to use a Java class from JRuby (that's in principle possible),
> > but my JRuby script reads the definition with the curly brackets as
> > a Hash (Ruby syntax), and I am searching for a way to prevent that.
> > 
> > Thank you very much for further help!
> > 
> > Best regards,
> > 
> > Axel
> > --
> > GRATIS fr alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> 
> I think I must be missing something.  Where is this definition coming
> from?
> 
> Correct me if I'm wrong, but this is what I think you're asking...
> 
> You have a java library with a method that takes an matrix (an array of
> arrays) and need to call that method using an object created in JRuby yes?
> 
> If that”Ēs the case you should (and I'm not a JRuby user so don't shoot
> me
> if I'm wrong)  be able to create an matrix using the ruby syntax:
> 
> a = [[1.1, 1.2, 1.3, 1.4], [2.1, 2.2, 2.3, 2.4], [3.1, 3.2, 3.3, 3.4]]
> 
> and then call the Java method on that JRuby maxtrix:
> b=Class.method(a)
> 
> and through the magic of JRuby all should be well.
> 
> If I've misunderstood please clarify.  I think half the reason you
> haven't gotten many responses is no one understands the question.
> 

Walton,

thanks for responding. Unfortunately, this is not a solution.
I really need some advice from somebody who has worked with JRuby here,
I guess. I just cannot find a way of writing a Java Matrix without curly braces, yet the Ruby part of JRuby interprets curly braces as Hashes.

For conflicts of Java and Ruby classes that have the same name, there
is this ( from the JRuby cookbook):

Example 1-7. Creating an alias to avoid class name conflicts
include Java

include_class 'java.lang.String' do |package,name|
    "JString"
end

p JString.new("A quick brown fox").indexOf("brown")

In this example, there is now a way of using Ruby Strings and Java 
Strings alongside, in the same program, without mixing them up,
by introducing a new name "JString" for the Java class "String".

I am looking for something similar that would work with curly braces
as a class method of the Java Matrix class in the *jar file I am using,
distinguishing it from the Ruby Hash declaration with curly braces,
preferably in a way that I could still use Ruby Hashes somewhere else
in my programs.... an alias or whatever, but cannot figure out how to do that.

Best regards,

Axel 
-- 
GRATIS fr alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01