Reverses a string.
Use String.split('')
and Iterable.reversed
to reverse the order of the runes in the string.
Use Iterable.join('')
to combine the runes and get the reversed string.
代码实现
String reverseString(String str) {
return str.split('').reversed.join('');
}
使用样例
reverseString('foobar'); // 'raboof'