The joined() method returns a new string by concatenating all the elements in an array, separated by a specified separator.
Example
joined() Syntax
The syntax of the joined() method is:
array.joined(separator: delimiter)
Here, array is an object of the Array class.
joined() Parameter
The joined() method takes one parameter:
- delimiter (optional) - the separator to join the elements
Note: If we call joined() without any parameter, the elements are joined without any separator.
joined() Return Value
- returns a string with all the array elements joined by a separator
Example: Swift joined()
Output
DellHPApple Dell HP Apple Dell, HP, Apple
Here, we can see that the joined() method converts all the array elements into a string and separates each element by the specified separator.