[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #42670] Input parser: dependence on the order
From: |
Damian Only |
Subject: |
[Octave-bug-tracker] [bug #42670] Input parser: dependence on the order of the arguments |
Date: |
Thu, 03 Jul 2014 12:29:43 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0 |
URL:
<http://savannah.gnu.org/bugs/?42670>
Summary: Input parser: dependence on the order of the
arguments
Project: GNU Octave
Submitted by: damianonly
Submitted on: Thu 03 Jul 2014 12:29:42 PM GMT
Category: Libraries
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 3.8.1
Operating System: GNU/Linux
_______________________________________________________
Details:
parameter parsing depends on the order of the arguments. Thefollowing code
snippet illustrates this:
varargin = {'pval0', 0, 'pval1', 1, 'pval2', 2};
varargin1 = {'pval0', 0, 'pval2', 2, 'pval1', 1};
p = inputParser;
p.CaseSensitive = true;
p.KeepUnmatched = true;
p = p.addParamValue('pval0', 0, @isnumeric);
p = p.addParamValue('pval2', 0, @isnumeric);
res = p.parse(varargin{:})
res = p.parse(varargin1{:})
In the first case, only 'pval0' will appear in the 'Results' field of 'res'.
However, if the order in which the arguments are passed is swapped, then both
'pval0' and 'pval1' are stored in 'Results'. The latter is the behavior I'd
expect.
In Matlab the last two lines in the snippet above yield the same results.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?42670>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #42670] Input parser: dependence on the order of the arguments,
Damian Only <=