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

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -