For Programmers: Free Programming Magazines  


Home > Archive > Ruby > August 2005 > Ruby documentation typo









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Ruby documentation typo
Behrang Saeedzadeh

2005-08-31, 7:57 am

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


David A. Black

2005-08-31, 7:57 am

Hi --

On Wed, 31 Aug 2005, Behrang Saeedzadeh wrote:

> 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 }
> ---
>
> 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.


Actually %w can take just about any delimiter:

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

etc. So you can definitely use {}.


David

--
David A. Black
dblack@wobblini.net


Behrang Saeedzadeh

2005-08-31, 7:57 am

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

On 8/31/05, David A. Black <dblack@wobblini.net> wrote:
>
> Hi --
>
> On Wed, 31 Aug 2005, Behrang Saeedzadeh wrote:
>
>
> Actually %w can take just about any delimiter:
>
> %w-a b c-
> %w!a b c!
>
> etc. So you can definitely use {}.
>
>
> David
>
> --
> David A. Black
> dblack@wobblini.net
>
>



--

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

Tim Hunter

2005-08-31, 7:57 am

Behrang Saeedzadeh wrote:
>
> 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.
Nikolai Weibull

2005-08-31, 7:57 am

Behrang Saeedzadeh wrote:

> 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

--
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


James Britt

2005-08-31, 7:00 pm

Behrang Saeedzadeh wrote:
> Hi David,
> Thanks for the information. Actually I'm new to Ruby, and I've not passed
> that page yet so...


Welcome to Rubyland!

James Britt

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys


Gennady Bystritksy

2005-08-31, 7:00 pm

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.

Behrang Saeedzadeh wrote:
> Hi David,
> Thanks for the information. Actually I'm new to Ruby, and I've not passed
> that page yet so...
> Best Regards,
> Behrang S.
>
> On 8/31/05, David A. Black <dblack@wobblini.net> wrote:
>
>
>
>




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com