Course of Raku / Addendum 🆕 / Working with data / Text and strings / Exercises / Reverse the word order
Solution: Reverse the word order
Here is a possible solution to the task.
Code
my $sentence = 'Raku is really nice';
say $sentence.words.reverse.join(' ');🦋 You can find the source code in the file reverse-words.raku.
Output
nice really is RakuComments
.wordsbreaks the sentence into a list,.reverseflips the list order, and.join(' ')glues the words back together with single spaces.