Sir, I do not understand the NEED for your explanation,Sir for I have not asked for one!!. Please go through original trigger. Mr.Karr was discussing correctly 1. misbehavior of boolean parameter in the middle of 24 parameters. He is correct. 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. So an work around if the Boolean is last the situation is Ok 2. calling a function with any number of parameters involves varag; calling with named parameters involves map. They are combined here. Those are the problems addressed. First line of my mail Both named and varag says that. Sent from Mail for Windows 10 From: CFouts It’s doing what you programmed it to do. You’re doing a “println” on the first arg (args.one), then a print on the second arg (args.two. So on your first 2 calls… f(one: “string”, two: false), prints string (the line fieed in println) false (no linefeed) then f(one: “string”, two: true), prints string (linefeed) true So if you combine the outputs, it’s indeed string (the line fieed in println) false (print, no linefeed) string (linefeed) true So. w/o the explanations, looks exactly what you have string false string true From: Rathinavelu <rathinav...@gmail.com> Both named and varag def f(Object[] args){ println args.one print args.two } f(one: "string",two:false) f(one:"string", two:true) f(two:false) f(two:true) f(two: 1==2) f(two: 1==1) f(two: 1==2) [string] [false][string] [true][null] [false][null] [true][null] [false][null] [true][null] [false] Please as a work around keep the boolean as the last parameter. Since map is a subclass of Object, the function polymorphically accepts map object . But why Boolean be the last to work? Sorry, Sir! I am into groovy only from last week! A long way to go! The reason for always ‘false’ in the middle perhaps is “invisible input”. Last output has no [null] T.Rathinavelu Sent from Mail for Windows 10 From: MG Hi David, On 25/04/2020 20:57, David Karr wrote:
|
- Strategy for optionally excluding a named method parameter? David Karr
- RE: Strategy for optionally excluding a named method para... Rathinavelu
- RE: Strategy for optionally excluding a named method para... Rathinavelu
- RE: Re: Strategy for optionally excluding a named method ... Rathinavelu
- FW: RE: Re: Strategy for optionally excluding a named met... Rathinavelu
- RE: Re: Strategy for optionally excluding a named method ... Rathinavelu
- Re: Strategy for optionally excluding a named method para... CFouts
- RE: Re: Strategy for optionally excluding a named method ... Rathinavelu
- RE: Re: Re: Strategy for optionally excluding a named met... Rathinavelu