View Problem

Reverse the words in a string

Given the string "This is a end, my only friend!", produce the string "friend! only my end, the is This"
ExpandDiskEdit
ruby
reversed = text.split.reverse.join(' ')
ExpandDiskEdit
csharp 3.0
var str = "This is a end, my only friend!";
str = String.Join(" ", str.Split().Reverse().ToArray());
Console.WriteLine(str);
ExpandDiskEdit
cpp C++/CLI .NET 2.0
array<Char>^ sep = {L' '};
array<String^>^ words =
String(L"This is the end, my only friend!").Split(sep, StringSplitOptions::RemoveEmptyEntries);

Array::Reverse(words); String^ newwords = String::Join(L" ", words);
ExpandDiskEdit
cpp
std::string words = "This is the end, my only friend!"; std::vector<std::string> swv;

boost::split(swv, words, boost::is_any_of(" ")); std::reverse(swv.begin(), swv.end());
std::string newwords = (std::for_each(swv.begin(), swv.end(), StringTAndJ())).value();
ExpandDiskEdit
erlang
Reversed = string:join(lists:reverse(string:tokens("This is the end, my only friend!", " ")), " "),

Submit a new solution for ruby, csharp, cpp, or erlang
There are 22 other solutions in additional languages (clojure, fantom, fsharp, go ...)