Search code examples
arraysstringvala

Vala - How to join string[] to string?


I have a string array:

string[] arr = {"Hello", "World"};

I want to print it or convert it to a string like:

print(arr.join(","));

> "Hello,World"

How can I do this?


Solution

  • Use string.joinv():

    string[] arr = {"Hello", "World"};
    
    print(string.joinv(",", arr));
    

    Result:

    Hello,World