1.python的默认入参:
def function(data=[]):
data.append(1)
return data
有个缺点,就是默认的入参好像必需放在变量入参的后面,不然会报错
2.java使用重载方式进行设置默认参数:
publicvoidTest(intlevel)
{floatmoney=0.0f;
booleanratable=true;
Test1(level,money,ratable);
}
publicvoidTest1(intlevel,floatmoney)
{
booleanratable=true;
TestParameter(level,money,ratable);
}
publicvoidTest1(intlevel,floatmoney,booleanratable)
{
//最终实现在这里
}