Closed
Description
source:
http://jruby.org/apidocs/org/jruby/embed/ScriptingContainer.html
This example:
Example 4:
ScriptingContainer container = new ScriptingContainer();
script =
"def message\n" +
"\"message: #\"\n" +
"end\n" +
"message";
container.put("@message", "What's up?");
EvalUnit unit = container.parse(script);
IRubyObject ret = unit.run();
System.out.println(JavaEmbedUtils.rubyToJava(ret));
container.put("@message", "Fabulous!");
ret = unit.run();
System.out.println(JavaEmbedUtils.rubyToJava(ret));
container.put("@message", "That's the way you are.");
ret = unit.run();
System.out.println(JavaEmbedUtils.rubyToJava(ret));
first of all, the script variable needs a type (String)
But even after adding it, the script outputs the following:
message: #
message: #
message: #
same result also when initializing the scripting container with LocalVariableBehavior.PERSISTENT
tested with jruby 1.7.18