Ruby documentation typo

B

Behrang Saeedzadeh

Hi all

I just stumbled upon a typo in the Ruby documentation and thought it
would be OK to mention it here.

The typo is at the http://www.rubycentral.com/book/intro.html page:

---
Sometimes creating arrays of words can be a pain, what with all the
quotes and commas. Fortunately, there's a shortcut: %w does just what
we want.

a =3D %w{ ant bee cat dog elk }
---

I guess, the %w{ ant bee cat dog talk } must be %w[ ant bee cat dog
talk] as we're talking about arrays and not hashes.

Best regards,
--=20

Behrang Saeedzadeh
http://www.jroller.com/page/behrangsa
 
D

David A. Black

Hi --

Hi all

I just stumbled upon a typo in the Ruby documentation and thought it
would be OK to mention it here.

The typo is at the http://www.rubycentral.com/book/intro.html page:

---
Sometimes creating arrays of words can be a pain, what with all the
quotes and commas. Fortunately, there's a shortcut: %w does just what
we want.

a = %w{ ant bee cat dog elk }

Actually %w can take just about any delimiter:

%w-a b c-
%w!a b c!

etc. So you can definitely use {}.


David
 
T

Tim Hunter

Behrang said:
I guess, the %w{ ant bee cat dog talk } must be %w[ ant bee cat dog
talk] as we're talking about arrays and not hashes.

The character following %w can be any "non-alphabetic or non-multibyte
character." (I'm quoting from pp. 303-304 in the 2nd Ed.) %w always
creates an array of strings, regardless of what delimiter character you use.
 
B

Behrang Saeedzadeh

------=_Part_2812_27873484.1125490924314
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi David,
Thanks for the information. Actually I'm new to Ruby, and I've not passed=
=20
that page yet so...
Best Regards,
Behrang S.

On 8/31/05 said:
=20
Hi --
=20
On Wed, 31 Aug 2005, Behrang Saeedzadeh wrote:
=20
=20
Actually %w can take just about any delimiter:
=20
%w-a b c-
%w!a b c!
=20
etc. So you can definitely use {}.
=20
=20
David
=20
--
David A. Black
(e-mail address removed)
=20
=20


--=20

Behrang Saeedzadeh
http://www.jroller.com/page/behrangsa

------=_Part_2812_27873484.1125490924314--
 
N

Nikolai Weibull

Behrang said:
Actually I'm new to Ruby, and I've not passed that page yet so...

You can try the examples in the book in the interactive ruby shell, irb.
Try running it as

% irb

at your shell prompt and then just paste the examples and see the
results,
nikolai
 
G

Gennady Bystritksy

It may serve as a guideline for new people -- try finish the book before
filing bug/typo reports ;-).

Or, at least, try it in irb.

Welcome to Ruby :)

Gennady.
 

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

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,504
Latest member
SherryFerr

Latest Threads

Top