groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rathinavelu <rathinav...@gmail.com>
Subject RE: Re: Re: Strategy for optionally excluding a named method parameter?
Date Sun, 26 Apr 2020 06:12:22 GMT
<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>1. <i>Is there a concise groovy syntax
we could use that would optionally include or exclude a single parameter to the method?<o:p></o:p></i></p><p
class=MsoNormal>Yes <b>varags.</b> Combine<b> varag </b>and <b>map</b>
if named parameter is also required; <b>varag</b> with <b>Object[] args</b>
parameter does the job </p><p class=MsoNormal>2<i>.&quot;What we've
discovered from testing is that if we send a value as either &quot;true&quot; or &quot;false&quot;,
it acts as if we sent &quot;true&quot;.&quot;<o:p></o:p></i></p><p
class=MsoNormal>Yes You are right. The work around is keep the boolean as the last.</p><p
class=MsoNormal>Please check,Sir, and correct me if I am wrong.</p><p class=MsoNormal>3.Still
your implementation of function is not given, Sir.</p><p class=MsoNormal>T.Rathinavelu</p><p
class=MsoNormal><o:p>&nbsp;</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>&nbsp;</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>Sunday, April 26, 2020 11:34 AM<br><b>To: </b><a href="mailto:users@groovy.apache.org">users@groovy.apache.org</a><br><b>Subject:
</b>Re: Re: Strategy for optionally excluding a named method parameter?</p></div><p
class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><div><p
class=MsoNormal>On Sat, Apr 25, 2020 at 10:42 PM Rathinavelu &lt;<a href="mailto:rathinavelu@gmail.com">rathinavelu@gmail.com</a>&gt;
wrote:</p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in
0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Sir, &nbsp;I do not understand
the NEED for your explanation,Sir for I have not asked for one!!. Please go through original
trigger.</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Mr.Karr
was discussing &nbsp;<b>&nbsp;correctly </b></p><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>1. misbehavior of boolean &nbsp;parameter
in the middle of 24 parameters. He is <b>correct.</b></p><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>If Boolean is lonely param it
works OK. But Mr.Karr’s situation is real use case. In the middle both false and true evaluate
as false as Mr.Karr correctly points out.</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>So an work around
if the Boolean is last the situation is Ok </p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>2.
calling a function with any number of parameters&nbsp; involves <b>varag; </b>calling
with<b> named parameters </b>involves &nbsp;<b>&nbsp;map. </b>They
are combined here.</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b>&nbsp;</b></p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Those are the
problems addressed. First line of my mail</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b>Both
named and varag</b></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>says
that.</p></div></div></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p
class=MsoNormal>Frankly, I can't understand your point at all.&nbsp; At first, I thought
you didn't understand my problem, and were pointing out irrelevant facts. This reply makes
me think that perhaps you noticed some indication of something actually going wrong, but I
really can't tell.&nbsp; Please try again to describe what I have &quot;correctly
pointed out&quot;.</p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><blockquote
style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b>Sent:
</b>Sunday, April 26, 2020 9:00 AM<br><b>To: </b><a href="mailto:users@groovy.apache.org"
target="_blank">users@groovy.apache.org</a>; <a href="mailto:davidmichaelkarr@gmail.com"
target="_blank">David Karr</a><br><b>Subject: </b>Re: Strategy
for optionally excluding a named method parameter?</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>It’s doing
what you programmed it to do.</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>You’re doing
a “println” on the first arg (args.one), then a print on the second arg (args.two.</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>So on your first
2 calls…</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(one: “string”,
two: false), prints</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;
string (the line fieed in println)</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;
false (no linefeed)</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>then f(one:
“string”, two: true), prints</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string
(linefeed)</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
true</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>So if you combine
the outputs, it’s indeed</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;
string (the line fieed in println)</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;
false (print, no linefeed) string (linefeed)</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
true</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>So. w/o the
explanations, &nbsp;looks exactly what you have</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;
&nbsp;string</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;
false string</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;
true</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><div
style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;border-color:currentcolor
currentcolor'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span
style='font-size:12.0pt;color:black'>From: </span></b><span style='font-size:12.0pt;color:black'>Rathinavelu
&lt;<a href="mailto:rathinavelu@gmail.com" target="_blank">rathinavelu@gmail.com</a>&gt;<br><b>Reply-To:
</b>&lt;<a href="mailto:users@groovy.apache.org" target="_blank">users@groovy.apache.org</a>&gt;<br><b>Date:
</b>Saturday, April 25, 2020 at 9:23 PM<br><b>To: </b>&quot;<a
href="mailto:users@groovy.apache.org" target="_blank">users@groovy.apache.org</a>&quot;
&lt;<a href="mailto:users@groovy.apache.org" target="_blank">users@groovy.apache.org</a>&gt;,
&quot;<a href="mailto:users@groovy.apache.org" target="_blank">users@groovy.apache.org</a>&quot;
&lt;<a href="mailto:users@groovy.apache.org" target="_blank">users@groovy.apache.org</a>&gt;,
David Karr &lt;<a href="mailto:davidmichaelkarr@gmail.com" target="_blank">davidmichaelkarr@gmail.com</a>&gt;<br><b>Subject:
</b>RE: Re: Strategy for optionally excluding a named method parameter?</span></p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b>Both
named and varag</b></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>def f(Object[]
args){ println args.one</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>print
args.two }</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(one:
&quot;string&quot;,two:false)</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(one:&quot;string&quot;,
two:true)</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(two:false)</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(two:true)</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(two: 1==2)</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(two: 1==1)</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>f(two: 1==2)</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[string]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[false][string]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[true][null]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[false][null]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[true][null]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[false][null]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[true][null]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>[false]</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Please as a
work around keep the <b>boolean</b> as the last parameter. Since <b>map</b>
is a subclass of &nbsp;<b>Object,</b> the function polymorphically accepts
<b>map object</b> . But why Boolean be the last to work? Sorry, Sir! I am into
groovy only from last week! A long way to go!</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The
reason for always ‘false’ in the middle perhaps &nbsp;is “invisible input”. Last
output has no [null]</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>T.Rathinavelu</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Sent from <a
href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank">Mail</a> for
Windows 10</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><div
style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;border-color:currentcolor
currentcolor'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b>From:
</b><a href="mailto:mgbiz@arscreat.com" target="_blank">MG</a><br><b>Sent:
</b>Sunday, April 26, 2020 5:00 AM<br><b>To: </b><a href="mailto:users@groovy.apache.org"
target="_blank">users@groovy.apache.org</a>; <a href="mailto:davidmichaelkarr@gmail.com"
target="_blank">David Karr</a><br><b>Subject: </b>Re: Strategy
for optionally excluding a named method parameter?</p></div><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p class=MsoNormal
style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>Hi David,<br><br>since,
as was mentioned, named parameters are implemented as a map underneath in Groovy, you should
be able to remove the map entry of the parameter you do not want to pass, though I did not
try this myself...<br><br>Cheers,<br>mg</p><div><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>On 25/04/2020 20:57, David Karr
wrote:</p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>On Sat, Apr
25, 2020 at 2:00 AM Rathinavelu &lt;<a href="mailto:rathinavelu@gmail.com" target="_blank">rathinavelu@gmail.com</a>&gt;
wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid
windowtext 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-color:currentcolor
currentcolor currentcolor rgb(204,204,204)'><div><div><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>Named parameters
are not available in Groovy, say, as in Python., though they say it is. Groovy has only mapped
parameters. The earlier mail works for a single ‘named’ parameter; if there are more parameters
Groovy does not work as ‘expected’; it treats them only as positional parameters.</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>Kindly
mail me an use-case.</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>T.Rathinavelu</p></div></div></blockquote><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The code sample
looks something like this:</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;
functionName param1: value,</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
param2: value,</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
param3: value,</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
param4: value,</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
...</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
param25: value</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>For instance,
we need to make either the previous call or the following:</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div><div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;
functionName param1: value,</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
param2: value,</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
param3: value,</p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
... </p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
param25: value</p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Where the &quot;param4&quot;
key and value are not provided.&nbsp; Presently, we have an &quot;if&quot; checking
for a condition, followed by the &quot;true&quot; block with the first version of
the function call with 25 parameters, followed by the &quot;else&quot; and the &quot;false&quot;
block with the second version, which has 24 parameters, all the same values as in the first
block, except for the one key and value not provided in the second version.</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p></div></div><blockquote
style='border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-color:currentcolor
currentcolor currentcolor rgb(204,204,204)'><div><div><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>Sent
from <a href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank">Mail</a>
for Windows 10</p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p><div
style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;border-color:currentcolor'><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'><b>From:
</b><a href="mailto:davidmichaelkarr@gmail.com" target="_blank">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"
target="_blank">users@groovy.apache.org</a><br><b>Subject: </b>Strategy
for optionally excluding a named method parameter?</p></div><p class=MsoNormal
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p><div><div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>Lately
my only Groovy work is scripted pipelines in Jenkins, version 2.89.4 .</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>I'm
working with an api that is somewhat dumb in one respect.&nbsp; The method we call takes
~25 parameters.&nbsp; We send them as named parameters. One of the parameters is of boolean
type.&nbsp; What we've discovered from testing is that if we send a value as either &quot;true&quot;
or &quot;false&quot;, it acts as if we sent &quot;true&quot;.&nbsp; If
we construct the call without that parameter entirely, it acts as if we sent &quot;false&quot;.
I tried making it send null, but that just causes it to fail at runtime.&nbsp; We presently
have an &quot;if&quot; for that one flag, with two calls to the method, one taking
25 parameters, the other taking 24.&nbsp; It is really obnoxious.</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>Obviously,
the proper fix is to change their api so that it works correctly.&nbsp; The reality is,
that's not going to happen any time soon in geological terms.</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p></div><div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>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
style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:40.8pt'>&nbsp;</p></div></div></blockquote></div></div></blockquote><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;</p></div></div></blockquote></div></div><p
class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:4.8pt'>&nbsp;</p><p
class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>

Mime
View raw message