Hacker News new | ask | show | jobs
by brobinson 3747 days ago
Huh, I've been doing Ruby since 2008 and I've never seen a block passed to gsub/gsub!. Neat!

That said, a block isn't necessary here and the one-liner can be even shorter:

    @sentence.gsub!(/\b\w/, &:upcase)
&: call syntax is actually a little faster post 1.9, too.