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

changepoint_advi.fischer at extaccount.com changepoint_advi.fischer at extaccount.com
Thu Jan 7 16:41:43 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.

Well, there are at least 3 cases not covered yet:

- An empty script (i.e. consisting of white space only); maybe it returns nil, but this is not necessary the case and should be documented.

- A script with a syntax error

- The case where the script can't be found

In any case, you are right that this should be documented, and I will open an issue for this.

Ronald


> 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.
> >

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