Hacker News new | ask | show | jobs
by pacala 3752 days ago
I don't know Ruby and reached the same conclusion in about 15 seconds. Could be nice to make it a function [or name the results] "capitalizeWords(text)". Possibly adding indentation could help:

    @sentence = @sentence.
      split(' ').
      map!{ |x| 
        x = x[0..0].upcase << x[1..-1]
      }.
      join(' ')
[Edit: Fixed code, thanks knodi123]
1 comments

you want the . at the end of the line, so the interpreter knows to expect a continuation.