Capitalize all words in sentence string in Ruby
Your function name should be in snake_case, not PascalCase. (Thanks @rui.)
It seems like it would make more sense to use map than each here.
Ruby doesn't need explicit return.
You might even want to extend the base string class.


Here's my rendition:

class String
  def capitalize_words
    this.split.map { |x| x.capitalize }.join(" ")
    # or:     .map(&amp;:capitalize)
  end
end

"this IS a Test".capitalize_words # =&gt; "This Is A Test"