help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which behavior should I expect when using inputParser?


From: Juan Pablo Carbajal
Subject: Re: Which behavior should I expect when using inputParser?
Date: Tue, 17 Jun 2014 15:00:20 +0200

On Tue, Jun 17, 2014 at 2:55 PM, Damian <address@hidden> wrote:
>>> Recently I run into some unexpected (for me) behavior when using
>>> inputParser. Here is the example:
>>>
>>>     p = inputParser;
>>>     p.FunctionName = 'my_function;
>>>     p.CaseSensitive = true;
>>>     p.KeepUnmatched = true;
>>>
>>>     p = p.addOptional('local', 0, @isnumeric);
>>>
>>>     test = {'local', 15};
>>>
>>>     res = p.parse(test{:})
>>>
>
>> It seems like a bug to me. "local" has its default value so it seems
>> it is not parsed.
>> I know Carnë has been trying to replace inputParser with a matlab
>> equivalent one (dunno what are the diffs at the moment).
>> For the moment, could you use "addParamValue" and give a useful default 
>> value?
>
> If I use addParamValue the 'local' argument can end up either in
> res.Unmatched or in res.Results, depending on whether 'local' was
> passed as a parameter.
>
> The only workaround I can think of is to use addParamValue, as you
> suggested and then check where the parameter is:
>
>   if isfield(res.Unmatched, 'method')
>     method = res.Unmatched.method;
>   else
>     method = res.Results.method;
>   end
>
> Is it wise to report a bug?

I do not understand how do you want to use it. Indeed if you put true
in KeepUnmatched then it might end up there...when it was unmatched.
Lets start over again. What are you trying to accomplish?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]