From: Thomas Sawyer Date: 2010-08-31T02:59:29+09:00 Subject: [ruby-core:31954] [Ruby 1.9-Feature#3767][Open] String#scan enumerator? Feature #3767: String#scan enumerator? http://redmine.ruby-lang.org/issues/show/3767 Author: Thomas Sawyer Status: Open, Priority: Normal Category: lib Should String#scan return an Enumerator if no block is given? I came across this issue when testing a String extension I have that works in 1.8, but not 1.9 b/c String is no longer enumerable. class String # Returns an Enumerator for iterating over each # line of the string, stripped of whitespace on # either side. # def cleanlines(&block) if block scan(/^.*?$/) do |line| block.call(line.strip) end else Enumerator.new(self) do |output| scan(/^.*?$/) do |line| output.yield(line.strip) end end end end end ---------------------------------------- http://redmine.ruby-lang.org