在ActionScript3(Flash的编程语言,与Java非常相似,以至于令人不安)中,如果我正在定义一个函数,并希望用无穷的参数调用它,我可以这样做(restParam,我认为它被调用了):
function annihilateUnicorns(...unicorns):String {
for(var i:int = 0; i<unicorns.length; i++) {
unicorns[i].splode();
}
return "404 Unicorns not found. They sploded.";
}
(然后你可以这样称呼它:)annihilateUnicorns(new Unicorn(), new Unicorn(), new Unicorn(), new Unicorn());
最酷的是,所有这些额外的参数都存储在一个数组中。在python中我将如何做到这一点?这显然行不通:
def annihilateUnicorns (...unicorns):
for i in unicorns :
i.splode()
return "404 Unicorns not found. They sploded."
谢谢!:D个
相关问题 更多 >
编程相关推荐