groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Wagenleitner <john.wagenleit...@gmail.com>
Subject Re: foo() || return false ?
Date Mon, 17 Jul 2017 22:06:04 GMT
That is not a valid start of an expression which is expected for the binary
expression (expr || expr) so that's why it wont compile. I am not familiar
with Scriptler and it is hard to tell without some more context, but how
about just:

doSomething()

You can simplify by dropping the `|| false`.  If that's the last line in a
boolean returning method/context it will return true if doSomething()
returns a non-null/non-zero/non-false value, else false.  Otherwise you
could coerce the value to a boolean with:

doSomething() as boolean


On Mon, Jul 17, 2017 at 1:18 PM, Guy Matz <guymatz@gmail.com> wrote:

> Hello!
> I'm trying to do the following in scriptler (Jenkins), but I can't get
> this to work:
> doSomething() || return false
>
> This fails in scripler with:
>
> Execution of script [promoteBuild.groovy] failed - org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
> Script1.groovy: 51: unexpected token: return @ line 51, column 85.
>    doSomething() || return fal
>
>
> Anyone know why this seemingly valid groovy does not work in scriptler?
>
>
> Thanks!
>
>
> P.S. - I asked the jenkins community but no one responded
>
>

Mime
View raw message