# Meaning of %w

**URL:** <https://www.ruby-forum.com/t/meaning-of-w/141879>\
**Category:** Ruby\
**Created:** [July 1, 2008, 10:55am UTC](https://www.ruby-forum.com/t/meaning-of-w/141879 "2008-07-01T10:55:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [July 1, 2008, 10:55am UTC](https://www.ruby-forum.com/t/meaning-of-w/141879/1 "2008-07-01T10:55:44Z")

</div>

what is the meaning of %w. atlest in my copy of rubydoc, i could not  
find the w attribute in sprintf flag characters

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [July 1, 2008, 11:12am UTC](https://www.ruby-forum.com/t/meaning-of-w/141879/2 "2008-07-01T11:12:43Z")

</div>

On Jul 1, 2008, at 01:52 , Junkone wrote:

> what is the meaning of %w. atlest in my copy of rubydoc, i could not  
> find the w attribute in sprintf flag characters

%w doesn’t have to do with sprintf afaik.

Maybe you mean this instead:

> **[Ruby | zenspider.com | by ryan davis](https://www.zenspider.com/ruby/)**
>
> Ruby facts, opinions, source code, links, and stuff.

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [July 1, 2008, 11:27am UTC](https://www.ruby-forum.com/t/meaning-of-w/141879/3 "2008-07-01T11:27:55Z")

</div>

On Jul 1, 5:08 am, Ryan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Jul 1, 2008, at 01:52 , Junkone wrote:
> 
> > what is the meaning of %w. atlest in my copy of rubydoc, i could not  
> > find the w attribute in sprintf flag characters
> 
> %w doesn’t have to do with sprintf afaik.
> 
> Maybe you mean this instead:
> 
> [Ruby | zenspider.com | by ryan davis](http://www.zenspider.com/Languages/Ruby/QuickRef.html#12)

in rails, this is how it create the options for select box.  
\<%= select(:rawdata, :symbol, %w{ AUD.USD-IDEALPRO-CASH EUR.GBP-  
IDEALPRO-CASH EUR.JPY-IDEALPRO-CASH EUR.USD-IDEALPRO-CASH GBP.USD-  
IDEALPRO-CASH USD.CAD-IDEALPRO-CASH USD.CHF-IDEALPRO-CASH }) %\>

what does the %w signify.

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [July 1, 2008, 11:32am UTC](https://www.ruby-forum.com/t/meaning-of-w/141879/4 "2008-07-01T11:32:00Z")

</div>

From: Junkone [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

# what is the meaning of %w. atlest in my copy of rubydoc, i could not

# find the w attribute in sprintf flag characters

we may need a site search for ruby-doc, otherwise, nubies like me will  
have to look harder 😉

look for references to “array” in this page  
[Programming Ruby: The Pragmatic Programmer's Guide](http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html). you  
wont miss it.

hth. kind regards -botp

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [July 1, 2008, 11:30am UTC](https://www.ruby-forum.com/t/meaning-of-w/141879/5 "2008-07-01T11:30:50Z")

</div>

On 1 Jul 2008, at 10:22, Junkone wrote:

> > [Ruby | zenspider.com | by ryan davis](http://www.zenspider.com/Languages/Ruby/QuickRef.html#12)
> 
> in rails, this is how it create the options for select box.  
> \<%= select(:rawdata, :symbol, %w{ AUD.USD-IDEALPRO-CASH EUR.GBP-  
> IDEALPRO-CASH EUR.JPY-IDEALPRO-CASH EUR.USD-IDEALPRO-CASH GBP.USD-  
> IDEALPRO-CASH USD.CAD-IDEALPRO-CASH USD.CHF-IDEALPRO-CASH }) %\>
> 
> what does the %w signify.

Exactly what the link Ryan posted says. It creates an array by  
splitting the string you give it.

Fred

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [July 1, 2008, 11:40am UTC](https://www.ruby-forum.com/t/meaning-of-w/141879/6 "2008-07-01T11:40:51Z")

</div>

From: Junkone [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

# in rails, this is how it create the options for select box.

# \<%= select(:rawdata, :symbol, %w{ AUD.USD-IDEALPRO-CASH EUR.GBP-

# IDEALPRO-CASH EUR.JPY-IDEALPRO-CASH EUR.USD-IDEALPRO-CASH GBP.USD-

# IDEALPRO-CASH USD.CAD-IDEALPRO-CASH USD.CHF-IDEALPRO-CASH }) %\>

# what does the %w signify.

in ruby, i learn by reading ruby-doc, and do-ing it using irb 😉

a = %w{ AUD.USD-IDEALPRO-CASH EUR.GBP-IDEALPRO-CASH  
EUR.JPY-IDEALPRO-CASH EUR.USD-IDEALPRO-CASH GBP.USD-IDEALPRO-CASH  
USD.CAD-IDEALPRO-CASH USD.CHF-IDEALPRO-CASH }

a.class  
#=\> Array

p a  
[“AUD.USD-IDEALPRO-CASH”, “EUR.GBP-IDEALPRO-CASH”,  
“EUR.JPY-IDEALPRO-CASH”, “EUR.USD-IDEALPRO-CASH”,  
“GBP.USD-IDEALPRO-CASH”, “USD.CAD-IDEALPRO-CASH”,  
“USD.CHF-IDEALPRO-CASH”]

some more examples (note, i can change the delimiters)

a=%w[this is a test]  
#=\> [“this”, “is”, “a”, “test”]

a=%w(1 2 3 4)  
#=\> [“1”, “2”, “3”, “4”]

a=%w\<my name is bot\ pena\>  
#=\> [“my”, “name”, “is”, “bot pena”]

kind regards -botp

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [July 1, 2008, 12:10pm UTC](https://www.ruby-forum.com/t/meaning-of-w/141879/7 "2008-07-01T12:10:45Z")

</div>

On Jul 1, 5:36 am, Peña, Botp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> a=%w(1 2 3 4)  
> #=\> [“1”, “2”, “3”, “4”]
> 
> a=%w\<my name is bot\ pena\>  
> #=\> [“my”, “name”, “is”, “bot pena”]
> 
> kind regards -botp

aah. thanks a lot for showing a new way.
