The `join` method in Dart converts each element to a string and concatenates the strings using a specified separator.
The syntax of Runes.join() method is:
String join([String separator = "" ])
This join() method of Runes converts each element to a String and concatenates the strings.
Parameter | Optional/Required | Description |
---|---|---|
separator | optional | The string used to separate each element when concatenating. Defaults to an empty string if not provided. |
Runes.join() returns value of type String
.
In this example,
runes
from the string 'Hello'.join
method with a hyphen separator to concatenate the characters into a single string.void main() {
Runes runes = Runes('Hello');
String joinedString = runes.join('-');
print('Joined string: $joinedString');
}
Joined string: 72-101-108-108-111
In this example,
emojis
from the string '👋🏽🚀🌟'.join
method with a pipe separator to concatenate the emojis into a single string.void main() {
Runes emojis = Runes('🚀🌟');
String joinedEmojiString = emojis.join(' | ');
print('Joined emoji string: $joinedEmojiString');
}
Joined emoji string: 128640 | 127775
In this Dart tutorial, we learned about join() method of Runes: the syntax and few working examples with output and detailed explanation for each example.