7stud -- wrote in post #1090510:
>> ...which I currently have no idea how that could be useful, but it is
>> still interesting...  heh
>
> string = "Hello world, hello mars, goodbye world."
> word_count_for = Hash.new(0)
>
> string.scan(/\b \w+ \b/x) do |word|
>   word = word.downcase
>   word_count_for[word] += 1
> end
>
> p word_count_for
>
> --output:--
> {"hello"=>2, "world"=>2, "mars"=>1, "goodbye"=>1}

Hey, I said "currently have no idea"!  :)  Very cool example.

-- 
Posted via http://www.ruby-forum.com/.