Alle Sunday 21 September 2008, Jody Glidden ha scritto:
> If I try the following...
>
> "I love guitar playing".split {|s| s.capitalize}.join(" ")
>
> I would expect it to capitalize the first letter of each word but it
> doesn't seem to work.
>
> Any hints on what I'm doing incorrectly?


String#split doesn't take a block, so that the block you pass to it is 
ignored. What you wrote is equivalent to 

"I love guitar playing".split.join(" ")

To do what you want, you need to call map on the array returned by 
String#split:

"I love guitar playing".split.map{|s| s.capitalize}.join(" ")

I hope this helps

Stefano