Reputation: 7973
I would like to convert int to string:
int count = 1;
string val = <string>count;
the above gives me 'int' cannot be cast to 'string'
Is there a utility method to achieve this. I always have to search for this solution and thought this question would document the answer.
I think I can maybe use io:sprintf
and I can print using ,
separation in io:println
, but I would like to do this without stdlib.
Also in Ballerina we cannot concat a string and int as follows:
string val = "hello " + count;
what is the easiest way to do this?
Upvotes: 2
Views: 708
Reputation: 1122
We can use toString()
to convert int
to string
.
int count = 1;
string val = count.toString();
Upvotes: 4