我的代码连接两个字符串是非常简单的:
string baseUrl = "http://localhost:8080/";
string url = baseUrl.append(url_secret);
但我有一个错误:
Error: Different number of components on the left hand side (1) than on the right hand side (0).
--> test.sol:156:9:
|
156 | string url = baseUrl.append(url_secret);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
是什么错了吗?
# # #.append()
function 函数修改现有的字符串,因此不返回任何内容。
所以你可以打电话
string baseUrl = "http://localhost:8080/";
baseUrl.append(url_secret);
然后baseUrl会被修改。如果你想用新的值设置一个新的变量url,你可以这样做
string url = baseUrl;