0

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

string[index].capitalize! unless %w(the and over).include?(string[index])
dwilbank
  • 2,470
  • 2
  • 26
  • 37
John Oggy
  • 319
  • 1
  • 3
  • 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
  • 165,429
  • 45
  • 277
  • 381
Arjan
  • 6,264
  • 2
  • 26
  • 42
1

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

This would help you a lot.

Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317