[jruby] runScriptlet return value question (documentation is unclear)

Charles Oliver Nutter headius at headius.com
Wed Jan 6 08:09:42 JST 2016


You are correct; all scripts always return the last expression
evaluated, so there's not really any case where this wouldn't return a
result.

Feel free to send in a documentation patch for this.

- Charlie

On Tue, Jan 5, 2016 at 8:48 AM,
<changepoint_advi.fischer at extaccount.com> wrote:
> I find the documentation of ScriptingContainer.runScriptlet a bit unclear. It says:
>
>    public Object runScriptlet(String script)
>
>    Evaluates a script under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value. Right after the parsing, the script is evaluated once.
>
> How is the wording  "returns a result only if a script returns a value" to be understood?
>
> (1) "if a script returns a value" -> Since every Ruby Script returns a value (even if the value is nil), I guess this means "if the script can't be executed". Right?
>
> (2) "returns a result only" -> Does it mean, that, if (1) does not happen (i.e. error when running the script, or whatever), null is returned, or is it meant that some RuntimeException is thrown?
>
> Ronald
>
>
> If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.
>


More information about the JRuby mailing list