Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BBFC6200CD7 for ; Tue, 18 Jul 2017 03:21:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BA6601655AC; Tue, 18 Jul 2017 01:21:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D9BA01655AA for ; Tue, 18 Jul 2017 03:21:29 +0200 (CEST) Received: (qmail 48798 invoked by uid 500); 18 Jul 2017 01:21:28 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 48788 invoked by uid 99); 18 Jul 2017 01:21:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Jul 2017 01:21:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 3A775C039B for ; Tue, 18 Jul 2017 01:21:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.401 X-Spam-Level: X-Spam-Status: No, score=-0.401 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id NkYL0_B5jYXZ for ; Tue, 18 Jul 2017 01:21:26 +0000 (UTC) Received: from mail-ua0-f175.google.com (mail-ua0-f175.google.com [209.85.217.175]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 7FB8A5FB43 for ; Tue, 18 Jul 2017 01:21:25 +0000 (UTC) Received: by mail-ua0-f175.google.com with SMTP id z22so7063996uah.1 for ; Mon, 17 Jul 2017 18:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=zPFMpUb/HFdj0Ls6gy2436kxPxy56SoTudG4ssY+GLo=; b=EAOUtbSU6TAM6QGSyDmfgP/lobs/tcX+Qb0GiyIiCfUnIjMhO/QQlu8ICXk5uB6rwK 3p9wO+YC55rgIyCXkbrd2zntY/dlFQt++MVM+mswpWkkRorg0VZS5g19okECWenF0ztG cX0jwNrDqbhvlNaztSnU98SOvaPAUbFHn89rxbuLzZlN9ViTej96QDv0dRUcYQiS3QFJ IoUw77NYO2C/D9V9K+ZB1l2ClsJdeIXa6okF8qRPu01RiuxeihLremtg+ZHwIg0FsVWc o//Ky3Pfv2h8KNUuh/O72rthjUBqpKcavej8BSbpc9QCfD1mWxix0gRhaw07Hz1PtuSy oFbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=zPFMpUb/HFdj0Ls6gy2436kxPxy56SoTudG4ssY+GLo=; b=lwJP8bSBGZ0K1aEUsP5iLeTlqlrmEc6b17XQ9U0aOdRy4hkYPaaCsrGWFBRox4yfEl q9V6TSnbqqItMK1JMvxtdn0I+0cUjGswWaLorjVoirfP35eBeYkI+pVY/0vfD4zPA6JU a8NCkdJIuxnY8QSjG3uOiLUt0Vr30EgxItR/2HHeIdhQ787iqZQe1VsM+H/hYg66qO56 Nmtgpw+HKBN7nH+JNocTQEguSNqgqnoi357JN4Oe1FfG+nLUCoz0ocgcgTawng23wTJo WwJXf1HZFza6bU3hhdWHqcyy/belVPdIG1KSRudJC2/VOcOqW5BWE5DoMgilAJrU6s6W N+mg== X-Gm-Message-State: AIVw111FjHpLRW2HI4DSDTmBWCYUH2sKE1OZCOo5w8RyZkB0Sa0Jf0KI tsEsiUseZk2wRa5fRwnt1LzMYZVlUvtp X-Received: by 10.176.87.218 with SMTP id u26mr199960uac.116.1500340884284; Mon, 17 Jul 2017 18:21:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.61.74 with HTTP; Mon, 17 Jul 2017 18:21:23 -0700 (PDT) In-Reply-To: References: From: John Wagenleitner Date: Mon, 17 Jul 2017 18:21:23 -0700 Message-ID: Subject: Re: foo() || return false ? To: users@groovy.apache.org Content-Type: multipart/alternative; boundary="f403045f8f0873297105548d5518" archived-at: Tue, 18 Jul 2017 01:21:30 -0000 --f403045f8f0873297105548d5518 Content-Type: text/plain; charset="UTF-8" Since the `||` operator expects an expression a return statement is not valid there. If the goal is to call the method `doSomething()` and then return false, then both can be put on separate lines or a semicolon can be used to separate the statements to keep it a one-liner, e.g., `doSomething(); return false`. On Mon, Jul 17, 2017 at 5:24 PM, Guy Matz wrote: > Thanks so much for the reply! I'm not trying to do this, though: || false > > I'm trying to do this: || return false > > Is there a more groovy way? > > Thanks!! > > > On Mon, Jul 17, 2017 at 5:06 PM, John Wagenleitner < > john.wagenleitner@gmail.com> wrote: > >> 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 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 >>> >>> >> > --f403045f8f0873297105548d5518 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Since the `||` operator expects an expression a return sta= tement is not valid there.=C2=A0 If the goal is to call the method `doSomet= hing()` and then return false, then both can be put on separate lines or a = semicolon can be used to separate the statements to keep it a one-liner, e.= g., `doSomething(); return false`.

On Mon, Jul 17, 2017 at 5:24 PM, Guy Matz <guymatz= @gmail.com> wrote:
Thanks so much for the reply!=C2=A0 I'm not trying to do this,= though: || false

I'm trying to do this: || return f= alse

Is there a more groovy way?

Thanks!!


On Mo= n, Jul 17, 2017 at 5:06 PM, John Wagenleitner <john.wagenleitner= @gmail.com> wrote:
That is not a valid start of an expression which is expected for t= he 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 conte= xt, but how about just:

doSomething()

You can simplify by d= ropping the `|| false`.=C2=A0 If that's the last line in a boolean retu= rning method/context it will return true if doSomething() returns a non-nul= l/non-zero/non-false value, else false.=C2=A0 Otherwise you could coerce th= e value to a boolean with:

doSomething() as boolean

=

On Mon, Ju= l 17, 2017 at 1:18 PM, Guy Matz <guymatz@gmail.com> wrote:
Hello!
I'm trying to do t= he 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] f=
ailed - org.codehaus.groovy.control.MultipleCompilationErrorsExcepti=
on: startup failed:
Script1.groovy: 51: unexpected token: return @ line 51, column 85.
   doSomething() || return fal

Anyone know w=
hy this seemingly valid groovy does not work in scriptler?

Thanks!
P.S. - I asked the jen=
kins community but no one responded



--f403045f8f0873297105548d5518--