ruby-dev summary 21295-21366

M

Minero Aoki

Hi all,

This is a summary of ruby-dev ML in these days.

[ruby-dev:21296] test and sample directory

NAKAMURA Hiroshi suggested to locate tests and examples of
standard libraries in the CVS repository. Matz agreed with
him. Committers are recommended to place tests and examples
in following places:

test/Library_Name/test_*.rb
sample/Library_Name/*

[ruby-dev:21325] illegal member in %w array

K.Kosako reported that an unexpected member is included in %w
array:

% ruby -e 'p %w(a b \
c)'
["a", "b", "c"]

% ruby -e 'p %w(a b \
c)'
["a", "b", "", "c"] # third member is wrong

Matz regard it as a bug and modified %w feature.
On CVS HEAD, these expressions are evaluated as:

% ruby -e 'p %w(a b \
c)'
["a", "b", "\nc"]

% ruby -e 'p %w(a b \
c)'
["a", "b", "\n", "c"]

K.Kosako also pointed out that \\n works differently in single quote
string and single quote here-document:

p 'a\
b
'
--> "ab\n"


p(<<'EOS')
a\
b
EOS

--> "a\\\nb\n"

Matz modified these features, too. On CVS HEAD, these expressions
are evaluated as:

p 'a\
b
'
--> "a\\\nb\n"


p(<<'EOS')
a\
b
EOS

--> "a\\\nb\n"


Summary of feature changes:

* in %w array, '\' escapes all spaces (\ \r\n\t\f\v).

%w(a \
b

-> 1.8.0 ["a", "b"]
-> CVS HEAD ["a", "\nb"]


%w(a \
b

-> 1.8.0 ["a", "", "b"]
-> CVS HEAD ["a", "\n", "b"]

* In single quote string, '\' escapes only backslash itself.

'a\
b'

-> 1.8.0 "ab"
-> CVS HEAD "a\\\nb"


-- Minero Aoki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top