Hey -- new here to Java and to Mirah. I'm experimenting with using it in combination with the LeJos project to control lego robotics.
Trying to implement this java code is giving me trouble. Here's the spec from their tutorial:
Button.ENTER.addButtonListener(new ButtonListener() {
public void buttonPressed(Button b) {
LCD.drawString("ENTER pressed", 0, 0);
}
public void buttonReleased(Button b) {
LCD.clear();
}
});
And here's my (failing) Mirah implementation. Hopefully, there some dumb mistake that I just wouldn't think of:
class MyButtonListener
implements ButtonListener
def buttonPressed(b: Button):void
LCD.drawString("ESC pressed", 0, 6)
end
def buttonReleased(b: Button):void
LCD.drawString("ESC released", 0, 6)
end
end
// and later:
listener = MyButtonListener.new
Button.ESCAPE.addButtonListener(listener)
It gives me the following error:
$ mirahc --java --classpath /Users/peter/Downloads/leJOS_NXJ_0.9.1beta-3/lib/nxt/classes.jar test.mirah
Parsing...
test.mirah
Inferring types...
test.mirah:32: can't convert Mirah::JVM::Types::TypeDefinition into String
Button.ESCAPE.addButtonListener(listener)
Mirah::InternalCompilerError: can't convert Mirah::JVM::Types::TypeDefinition into String
infer at /Users/peter/.rvm/gems/jruby-1.6.7.2/gems/mirah-0.0.12-java/lib/mirah/typer/simple.rb:280
infer at /Users/peter/.rvm/gems/jruby-1.6.7.2/gems/mirah-0.0.12-java/lib/mirah/typer/simple.rb:275
resolve at /Users/peter/.rvm/gems/jruby-1.6.7.2/gems/mirah-0.0.12-java/lib/mirah/typer/simple.rb:324
each at org/jruby/RubyHash.java:1186
See the full docs:
Cheers & Thanks for any help!
--Peter