Skip to content
Snippets Groups Projects
subsasgn.m 837 B
Newer Older
function hash = subsasgn(hash, s, val)
% Subscripted assignment for object Hashtable
% overloading subscripted reference for objects
% Dot Notation vs. Function Notation
%
% ex: h = Hashtable('key', value)
% h.key = value
% h('key') = value
% see help for subsasgn
%
% $Id$
  case 2
    switch s(1).type
      case '.'
        h = get(hash, s(1).subs);
        h = put(h, s(2).subs, val);
        hash = put(hash, s(1).subs, h);
      otherwise
        error('Invalid type.')
    end
  case 1
    switch s.type

      case '()'
        if (length(s.subs) ~= 1)
          error('Only single indexing is supported.');
        end
        hash = put(hash,s.subs{1},val);
      case '.'
        hash = put(hash,s.subs,val);
      otherwise
        error('Invalid type.')