'Error with <string>.append() in ton-solidity: Different number of components on the left hand side (1) than on the right hand side (0)
My code for concatenating 2 strings is pretty simple:
string baseUrl = "http://localhost:8080/";
string url = baseUrl.append(url_secret);
But I have got an error:
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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What is wrong?
Solution 1:[1]
The .append()
function modifies the existing string, so nothing is returned.
So you can just call
string baseUrl = "http://localhost:8080/";
baseUrl.append(url_secret);
and then baseUrl
will be modified. If you want to set a new variable url
with the new value, you can do
string url = baseUrl;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | frozen |