From: Robert Klemme Date: 2009-12-10T18:58:04+09:00 Subject: Re: which is better? 2009/12/10 Wybo Dekker : > Robert Klemme wrote: > >> And then there's also >> >> irb(main):001:0> "123ab".tr "0-9", "" >> => "ab" >> irb(main):002:0> "123ab".tr! "0-9", "" >> => "ab" > > But why no parentheses?: > irb >>> $-w=true > => true >>> "abcd1234".gsub! /\d+/,'' > (irb):13: warning: ambiguous first argument; put parentheses or even spaces > => "abcd" >>> "123ab".tr! "0-9","" > => "ab" > > what is the ambiguity in the first case, and why is there no warning in the > second case? Seems to be related to the regexp: 10:56:19 $ ruby19 -wce 'o.gsub! /\d/, ""' -e:1: warning: ambiguous first argument; put parentheses or even spaces Syntax OK 10:56:42 $ ruby19 -wce 'o.gsub! "d", ""' Syntax OK 10:56:50 $ ruby19 -wce 'o.gsub!(/\d/, "")' Syntax OK 10:57:01 $ Why? No idea. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/