Assistance with Some Interesting Syntax in Some Ruby Code I've Found -


I am currently reading agile web development with Rail, version 3. On page 672, I came to this method:

  def capitalize_words (string) string.gsub (/ \ b \ w /) {$ &. Upcake} End  

What is the code doing in the block? I have never seen that syntax, is it like the array.map (& amp; some: method_method) syntax?

This input is the title wrapper inside the block, $ & amp; Represents an existing match (\ b \ w i.e. the first letter of each word), which is later upper.


Comments

Popular posts from this blog

Indexing in SQL -

objective c - iPhone and it's wireless area -

multithreading - Do lock objects in Java need to be static? -