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: Damian
Subject: Re: Which behavior should I expect when using inputParser?
Date: Tue, 17 Jun 2014 14:55:10 +0200

>> 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?



reply via email to

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