s = "The green hat is the twin of the green hat"
h = Hash.new(0)
s.split.each do |w|
...

Ruby Count words in a string

by andyjeffries, May 02, 2009 13:41, 16 refactorings, tagged with hash, string strip, simple

This is a coding question I...

5cb7a05b6de4a6655319db9333be429c Talk
class String
  def strip chars = "\s"
    gsub /^[#{chars}]+|[#{chars}}]+$/, ''
...

Ruby String#strip with char list

by Tj Holowaychuk, February 21, 2009 01:08, 6 refactorings, tagged with string strip

Better way?

F1e3ab214a976a39cfd713bc93deb10f Talk