Split warning

Thanks for the info. It is a relief.

-Ted

···

From POP3 Thu Aug 22 15:07:11 EDT 2002
Date: Fri, 23 Aug 2002 04:05:18 +0900
Posted: 22 Aug 2002 13:14:07 -0600
From: Tom Sawyer transami@transami.net
Subject: Re: split warning
To: ruby-talk@ruby-lang.org (ruby-talk ML)
X-ML-Name: ruby-talk
X-Mail-Count: 47935
X-MLServer: fml [fml 3.0pl#17]; post only (anyone can post)
X-ML-Info: If you have a question, send e-mail with the body
“help” (without quotes) to the address ruby-talk-ctl@ruby-lang.org;
help=mailto:ruby-talk-ctl@ruby-lang.org?body=help
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit

i believe the final decision was to change it per the overall opinions.
prior to this only a single character string was actually treated as a
string, all others were converted to regexp. now it will be as you have
pointed out: strings will be string and regexps regexps :slight_smile:

so:

“abc”.split(“\r\n”) # as string
“abc”.split(/\r\n/) # as regexp

the warning that you saw was put in to let people know about this
change. yes, some older code will have to be touched up.

~transami

p.s. please correct if i misrepresented any of this.

On Thu, 2002-08-22 at 11:12, mengx@nielsenmedia.com wrote:

Thanks.

I just browsed several records and seemed to me that
quite a few people (and including me) like to see that
“split” based on argument type. If it is a string, then
use string as the separator. For Regexp, use the Regexp.
This is basically the Ruby way to overload “split” method.

Was there a final decision on this? A lot of codes could break
due to this change.

Thanks

-Ted

From POP3 Thu Aug 22 12:37:00 EDT 2002
Date: Fri, 23 Aug 2002 00:32:26 +0900
Posted: 22 Aug 2002 09:41:13 -0600
From: Tom Sawyer transami@transami.net
Subject: Re: split warning
To: ruby-talk@ruby-lang.org (ruby-talk ML)
X-ML-Name: ruby-talk
X-Mail-Count: 47898
X-MLServer: fml [fml 3.0pl#17]; post only (anyone can post)
X-ML-Info: If you have a question, send e-mail with the body
“help” (without quotes) to the address ruby-talk-ctl@ruby-lang.org;
help=mailto:ruby-talk-ctl@ruby-lang.org?body=help
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit

see ruby-talk 44019 and subsequent responses

-transami

On Thu, 2002-08-22 at 08:38, mengx@nielsenmedia.com wrote:

Hi:

With the laster cvs version, ruby gives warning

$ruby -e ‘“abc”.split(“\r\n”)’
-e:1: warning: string pattern instead of regexp; metacharacters
no longer effective.

What is reason for this change?

Thanks

-Ted


~transami>


~transami>