From: Felix von Delius Date: 2001-04-22T22:40:03+09:00 Subject: [ruby-talk:14019] Re: regexp I'm interrested in this question, too: What side effects on the existing syntax would came up it have if a regular expression match (using match() or =~) checks for a block given and yields that block (in case the expression matches) with the regexp-groups as arguments? This way you could express code like this: m = /^(\d+),(\d+)$/.match(line) if m then first, second = m[1,2] print ">>#{first} >>#{second}\n" end much shorter and readable like this: /^(\d+),(\d+)$/.match(line) do | first, second | print ">>#{first} >>#{second}\n" end Wouldn't it be a large improvement? Would it break existing code? -Felix much easied James Ponder wrote: > On Sat, Apr 21, 2001 at 10:36:51PM +0900, ts wrote: >> >>>>> "J" == James Ponder writes: >> J> var =~ /^(.+)=(.+)$/ do |x,y| >> >> Invalid syntax actually. > > You think it would be too horrible if ruby allowed that syntax and called > method =~ with the block? Does that clash with existing syntax rules? > > What do I know. Just a suggestion :) > > > Best wishes, James