pb_remove.m

来自「matlab从入门到精通第13章书后源码对初学者很有帮助」· M 代码 · 共 15 行

M
15
字号
function pb_remove(pb_htable,name)
% 从电话本中删除记录
% 检查用户是否存在
if ~pb_htable.containsKey(pb_keyfilter(name))
   disp(sprintf('The name %s is not in the phone book',name))
   return
end;
% 如果用户存在,确定后删除电话
r = input(sprintf('Remove entry %s (y/n)? ',name), 's');
if r == 'y'
   pb_htable.remove(pb_keyfilter(name));
   disp(sprintf('%s has been removed from the phone book',name))
else
   disp(sprintf('%s has not been removed',name))
end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?