From: Gavin Sinclair Date: 2003-09-19T11:30:54+09:00 Subject: Re: Why IO#readlines does'nt accept a Regexp? On Friday, September 19, 2003, 11:20:47 AM, Gavin wrote: > Or if you want to use the latest and greatest: > require 'set' > words = Set.new > IO.foreach("myfile") do |line| > line.scan(/\w+/).each { |w| words << w } > end One better: require 'set' words = Set.new IO.foreach("myfile") do |line| words.merge(line.scan(/\w+/)) end Gavin