默认参数指定不允许不允许、参数

由网友(凉了时光空了旧城)分享简介:我有以下的code,让错误默认参数指定不允许这怎么能解决吗?布尔listSubscribe(字符串apikey,字符串ID,串EMAIL_ADDRESS,字符串[] merge_vars,字符串email_type =HTML,布尔double_optin =假,布尔replace_interests = TRUE,布...

我有以下的code,让错误

  

默认参数指定不允许

这怎么能解决吗?

 布尔listSubscribe(字符串apikey,
                   字符串ID,
                   串EMAIL_ADDRESS,
                   字符串[] merge_vars,
                   字符串email_type =HTML,
                   布尔double_optin =假,
                   布尔replace_interests = TRUE,
                   布尔send_welcome = FALSE);

布尔listUnsubscribe(字符串apikey,
                     字符串ID,
                     串EMAIL_ADDRESS,
                     布尔delete_menber =假,
                     布尔send_goodbye = TRUE,
                     布尔send_notify = TRUE);
 

解决方案

根据你的错误信息,你可以这样做,在v3.5版本。

解决方法是多个构造函数:

 布尔listUnsubscribe(字符串apikey,
                     字符串ID,
                     串EMAIL_ADDRESS){
  返回listUnsubscribe(apikey,ID,EMAIL_ADDRESS,假的,真正的,真实的);
}

布尔listUnsubscribe(字符串apikey,
                     字符串ID,
                     串EMAIL_ADDRESS,
                     布尔delete_menber,
                     布尔send_goodbye,
                     布尔send_notify){
  返回什么;
}
 

Python 定义函数

I have the following code that gives the error

Default parameter specifiers are not permitted

How can this be fixed?

bool listSubscribe(string apikey,
                   string id, 
                   string email_address,
                   string [] merge_vars,
                   string email_type="html",
                   bool double_optin=false,
                   bool replace_interests=true,
                   bool send_welcome=false);

bool listUnsubscribe(string apikey, 
                     string id, 
                     string email_address, 
                     bool delete_menber=false,
                     bool send_goodbye=true,
                     bool send_notify=true);

解决方案

As per your error message, you can't do that in v3.5.

The work around is multiple constructors:

bool listUnsubscribe(string apikey, 
                     string id, 
                     string email_address) {
  return listUnsubscribe(apikey, id, email_address, false, true, true);
}

bool listUnsubscribe(string apikey, 
                     string id, 
                     string email_address, 
                     bool delete_menber,
                     bool send_goodbye,
                     bool send_notify) {
  return whatever;
}

阅读全文

相关推荐

最新文章