~ubuntu-branches/ubuntu/wily/octave-struct/wily

« back to all changes in this revision

Viewing changes to inst/setfields.m

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Rafael Laboissiere
  • Date: 2015-07-19 18:53:13 UTC
  • mfrom: (9.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150719185313-rmhr0hmmx4kdp8gv
Tags: 1.0.11-1
[ Rafael Laboissiere ]
* Imported Upstream version 1.0.11
* d/p/autoload-yes.patch: Remove patch (deprecated upstream)
* d/check.m: Remove this obsolete file

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
## this program; if not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
## -*- texinfo -*-
19
 
## @deftypefn {Function File} {} @var{s} = setfields(@var{s},@var{key},@var{value},...)
 
19
## @deftypefn {Function File} {@var{s} =} setfields(@var{s},@var{key},@var{value}, @dots{})
20
20
## Sets @var{s}.@var{key1} = @var{value1},  @var{s}.@var{key2} = @var{value2}, etc, finally
21
 
## returning s.
 
21
## returning @var{s}.
22
22
## For some compatibility and flexibility.
23
23
## @seealso{cmpstruct, fields, rmfield, isstruct, getfields, isfield,struct}
24
24
## @end deftypefn
43
43
  else
44
44
    error ("structure must be scalar or empty");
45
45
  endif
46
 
 
47
 
%!assert (setfields ({}, 'key', 'value'), struct ('key', 'value'));
 
46
endfunction
 
47
 
 
48
%!assert (setfields ({}, "key", "value"), struct ("key", "value"));
 
49
 
 
50
%!shared s, t
 
51
%! t = struct ("hello", 1, "world", 2);
 
52
%! s = struct ("foo", "bar", "bye", "ciao");
 
53
%! t = setfields (t, "foo", "bar", "bye", "ciao");
 
54
%!assert ({t.foo t.bye}, {s.foo s.bye})