<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta
http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft
Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Latha;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div
class=WordSection1><p class=MsoNormal>Sir, </p><p class=MsoNormal>I find
no problem.</p><p class=MsoNormal>groovy> def f(boolean b) { println b}
</p><p class=MsoNormal>groovy> f(b=false) // named</p><p class=MsoNormal>groovy>
f(b=!false) </p><p class=MsoNormal>groovy> boolean bb = 7==70 </p><p
class=MsoNormal>groovy> f(b=bb) </p><p class=MsoNormal>groovy>
bb = 7==7 </p><p class=MsoNormal>groovy> f(b=bb) </p><p class=MsoNormal> </p><p
class=MsoNormal>false</p><p class=MsoNormal>true</p><p class=MsoNormal>false</p><p
class=MsoNormal>true</p><p class=MsoNormal>Perhaps I do not understand the
situation. May you kindly post me the failing use-case.</p><p class=MsoNormal>T.Rathinavelu</p><p
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent
from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows
10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid
#E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From:
</b><a href="mailto:davidmichaelkarr@gmail.com">David Karr</a><br><b>Sent:
</b>Saturday, April 25, 2020 1:48 AM<br><b>To: </b><a href="mailto:users@groovy.apache.org">users@groovy.apache.org</a><br><b>Subject:
</b>Strategy for optionally excluding a named method parameter?</p></div><p
class=MsoNormal><o:p> </o:p></p><div><div><div><p
class=MsoNormal>Lately my only Groovy work is scripted pipelines in Jenkins, version 2.89.4
.</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p
class=MsoNormal>I'm working with an api that is somewhat dumb in one respect.
The method we call takes ~25 parameters. We send them as named parameters. One of
the parameters is of boolean type. What we've discovered from testing is that if
we send a value as either "true" or "false", it acts as
if we sent "true". If we construct the call without that parameter
entirely, it acts as if we sent "false". I tried making it send null, but
that just causes it to fail at runtime. We presently have an "if"
for that one flag, with two calls to the method, one taking 25 parameters, the other taking
24. It is really obnoxious.</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p
class=MsoNormal>Obviously, the proper fix is to change their api so that it works correctly.
The reality is, that's not going to happen any time soon in geological terms.</p></div><div><p
class=MsoNormal><o:p> </o:p></p></div><div><p
class=MsoNormal>Is there a concise groovy syntax we could use that would optionally include
or exclude a single parameter to the method?</p></div></div></div><p
class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>
|