Actions
Feature #3767
closedString#scan enumerator?
Feature #3767:
String#scan enumerator?
Status:
Rejected
Assignee:
-
Target version:
-
Description
=begin
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
=end
Actions