Reputation: 10686
I have the following program:
class Matcher
include Enumerable
def initialize(string, match)
@string = string
@match = match
end
def each
@string.scan(/[@#match]/) do |pattern|
yield pattern
end
end
end
mch = Matcher.new("the quickbrown fox", "aeiou")
puts mch.inject {|x, n| x+n}
It is supposed to match the characters, aeiou
with the string the quickbrown fox
No matter what I put as the pattern, it oddly prints out the characters: thc
. What's going on?
Upvotes: 0
Views: 74
Reputation: 426
@string.scan(/[@#match]/) do |pattern|
is incorrect. #{@match}
is what you're looking for.
Upvotes: 3