Python论坛  - 讨论区

标题:Re: [python-chinese] How to prevent calling the clear method of the list?

2005年06月06日 星期一 17:27

Jay wz12 at yeah.net
Mon Jun 6 17:27:18 HKT 2005

public const List void getStaffList() {
                  ~~~~~???????
        return staffList

> 上次面试的时候一个老外问的,我说在getStaffList()中对于staffList做个

> protected-copy,他没反应。

> 大家帮着想一想!谢谢啊!

> 

> pilbic class Company {

>     private List staffList;

> 

>     public List void getStaffList() {

>         return staffList;

>     }

> 

> .....

> }

> 

> public class EvilAgency() {

> 

>     public void buildContact() {

> 

>         List stafflist = myCompany.getStaffList();

>         .....

>         stafflist.clear(); //how to prevent this occuring?

>     .....

>     }

> ......

> }

> 

> _______________________________________________

> python-chinese list

> python-chinese at lists.python.cn

> http://python.cn/mailman/listinfo/python-chinese

> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050606/b353346f/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号