Search Postgresql Archives

Re: [HACKERS] string_to_array with empty input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mar 30, 2009, at 8:26 PM, Tom Lane wrote:

Does anyone want to argue for keeping it the same?  Or perhaps
argue that a zero-element array is a more sensible result than
a one-element array with one empty string?  (It doesn't seem
like it to me, but maybe somebody thinks so.)

Hrm. There seems to be some disagreement about this among some languages:

% perl -le '@r = split /-/, ""; print length @r; print qq{"$r[0]"}'
1
""

% irb
>> puts ''.split('-')
=> nil

So Perl returns a single element as Steve had been expecting, while Ruby returns nil. I'm used to the Perl way, but I guess there's room for various interpretations, including the current implementation, with which Ruby would seem to agree.

Best,

David

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux