From: "Thairuby ->a, b {a + b}" Date: 2009-09-28T05:20:00+09:00 Subject: Re: handling of regexp objects that aren't referenced by variables, arrays, tables or objects Thairuby ->a, b {a + b} wrote: > Is this ok? But it still use variable :( > > file.each_line { |line| > if line =~ (a ||= $line_patterns["pattern a"]) > process_pattern_a(line) > elsif line =~ (b ||= $line_patterns["pattern b"]) > process_pattern_b(line) > # some more elsifs > end > } I'm wrong typing. It would be file.each_line { |line| if line =~ (a ||= /^pattern[a]*/) process_pattern_a(line) elsif line =~ (b ||= /pat+e(rn)? b\s*$/) process_pattern_b(line) # some more elsifs end } Does it have o option for string? :) -- Posted via http://www.ruby-forum.com/.