0

I don't understand "%W" - what does that mean?

string[index].capitalize! unless %w(the and over).include?(string[index])
dwilbank
  • 2,412
  • 2
  • 22
  • 35
John Oggy
  • 199
  • 1
  • 2
  • 14
  • 1
    Your question asks what `%W` means (uppercase "W"), but your example uses `%w` (lowercase "w"). They mean subtly different things, so which do you want to know about? – Jon Cairns Apr 11 '13 at 09:11

2 Answers2

2

%w creates an array based on the words in it (whitespace separated).

So

%w(the and over)

Will become

["the", "and", "over"]

It is a commonly used method in ruby.

So a portion of your string will be capitalized, unless that portion is either "the", "and" or "over".

sawa
  • 160,959
  • 41
  • 265
  • 366
Arjan
  • 6,234
  • 2
  • 24
  • 42
1

Check %Q, %q, %W, %w, %x, %r, %s.

This would help you a lot.

Arup Rakshit
  • 113,563
  • 27
  • 250
  • 306