On Mon, Jan 28, 2013 at 6:55 PM, Jesús Gabriel y Galán
<[email protected]> wrote:
> res = Hash.new(0)
> string.downcase.scan(/\w+/) {|word| res[word] += 1}
> return res
And to answer Wayne's question how to get rid of the "return":
Hash.new(0).tap do |res|
string.downcase.scan(/\w+/) {|word| res[word] += 1}
end
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
--
[email protected] |
https://groups.google.com/d/forum/ruby-talk-google?hl=en
---
You received this message because you are subscribed to the Google Groups
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.